From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28978 invoked by alias); 4 Mar 2015 19:18:34 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19970 Received: (qmail 11082 invoked from network); 4 Mar 2015 19:18:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, T_FSL_HELO_BARE_IP_2 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1425496053; bh=MJWo7dKmjSn8g5JKb9knfIwCpPQZV43xeb94E6ml5QQ=; h=From:To:Cc:In-Reply-To:References:Subject:Date; b=IShEKH4WJYU1qCT33UZFb5UdDvdforKi/5BApRAF9m2YbiYEYb+OVUIJTP8zZvx0t aXpR5KnyG93AiLGP9Km8YM/O0yJfllqnvA/+ex5ChKnwHXaaKcRJWcLnlr25AR+fDw E28zMDa0Trbcat8KA5rEUzXbVaYCUzdeFZBkPRt8= From: ZyX To: Kurtis Rader Cc: Zsh Users , Ray Andrews In-Reply-To: References: <54F33934.2070607@eastlink.ca> <13666281425228233@web7o.yandex.ru> <54F345D3.9010204@eastlink.ca> <20150302022754.GA7449@xvii.vinc17.org> <54F3E489.5050603@eastlink.ca> <54F48D26.6040303@eastlink.ca> <3716401425322991@web19h.yandex.ru> <2721791425356115@web16g.yandex.ru> Subject: Re: grammar triviality with '&&' MIME-Version: 1.0 Message-Id: <4572711425496052@web9o.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Wed, 04 Mar 2015 22:07:32 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r 03.03.2015, 07:44, "Kurtis Rader" : > On Mon, Mar 2, 2015 at 8:15 PM, ZyX wrote: >> šI do not think this is a mistake. And I found at least two differences: >> >> š1. `command test --help` returns zero, `command \[ --help` displays help. >> š2. `[` requires `]` (unless it received `--help` or `--version`), no >> šmatter what name it is called with, `test` requires not. >> >> šNote that coreutils ebuild does *not* contain any references to `test` or >> š`[`, patches as well do not (except when Makefile is patched not to >> šregenerate man pages). This means that this difference is created by GNU >> šdevelopers, *not* by distro maintainers. > > Ugh! I can confirm your observations using my Ubuntu 14.04 server. Yet on > Mac OS X Yosemite the two names are linked to the same binary. Mac OS X > exhibits the traditional behavior. I have no idea why GNU based distros > have the two names linked to slightly differently behaving binaries. > Presumably the GNU team had a good reason for this departure from the > traditional behavior. Furthermore, the GNU team could have used a single > binary for both names since a program can easily use the name it was > invoked by to alter its behavior. But that difference doesn't affect my > point that traditionally /bin/test and /bin/[ referred to the same program > and /bin/sh didn't know how to do anything other than invoke an external > command with a sequence of "words" and evaluate its exit status. So "if [ > some condition ]; then" was really just "if /bin/[ some condition \] ; > then". If you want `test` and `[` point to the same executable on Gentoo you can compile coreutils with USE=multicall. According to the description this will make *all* programs from coreutils package be compiled into a single executable. Other than that these programs have different behavior (required by the standard according to Vincent Lefevre). The only possible purpose for making them point to one executable with this remark is saving space*. But this is the case for USE=multicall (its purpose is explained directly in USE flag description). * I would actually try to refactor this into 2 executables + library, but after reading ldd output for a few coreutils executables it now looks like coreutils developers thought that the least amount of linked libraries is the best option. As long as test and [ live in one repository this does not affect code reusage at all. > > Note that quoting is critical. Which is the main reason the Korn-shell > (ksh) introduced the "[[ ... ]]" syntax. Invoking /bin/[ (or /usr/bin/[) > requires a trailing "]". Invoking /bin/test (or /usr/bin/test) requires > that there be no trailing "]". How the arguments are passed to the two > commands is also important. The "/bin/[" form requires that the shell has > already tokenized the condition into words. > > -- > Kurtis Rader > Caretaker of the exceptional canines Junior and Hank