From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15285 invoked by alias); 3 Mar 2015 04:43:33 -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: 19965 Received: (qmail 24375 invoked from network); 3 Mar 2015 04:43:31 -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.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Wm8Kue9kWdXWZri0a0B4rTJ9I/oaqUiESap7w8+MoXY=; b=PxwV+0a9a27VYT9t8D4KFE9XeQVXptnrlfSgV6m+bVI3W706BxnMGiQLeX2d0jkMRR FH/n1MIBzbaDK3fi2lj3rQQkzpmLAgTFXa/Ht9IsVKsQd6P+wC/Rkb8wrxyvMg7U28zS en+/6XTek4Zhr52/vmW9PxOtEBqTb+Jb6WyG1PAsnkhgOMeuJ4uUYj1KZH5HMtWtDLLQ Bzdx4sDEUV8EZq2XRSbxFuI7cxviFYQQpDoaQZDcVq1ddVrJy1BIBXNXqMDxXxDhI1/t mc3hYSDuJmcAaKa3hdIjWiiQCzijQMeyJPHWKkTyh6P4Bh/VFZmfs+dnZmIwvABBcYe+ Nnog== X-Gm-Message-State: ALoCoQmNz368HWMMKiZqKI3iDtbQIe6NPpXX+uadXx60E3TlH3w0Gzylgr342bJOgQouMGldRyGB MIME-Version: 1.0 X-Received: by 10.152.36.70 with SMTP id o6mr3060771laj.111.1425357807491; Mon, 02 Mar 2015 20:43:27 -0800 (PST) In-Reply-To: <2721791425356115@web16g.yandex.ru> 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> Date: Mon, 2 Mar 2015 20:43:27 -0800 Message-ID: Subject: Re: grammar triviality with '&&' From: Kurtis Rader To: ZyX Cc: Zsh Users , Ray Andrews Content-Type: multipart/alternative; boundary=089e0160b618cb30bb05105af9b5 --089e0160b618cb30bb05105af9b5 Content-Type: text/plain; charset=UTF-8 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". 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 --089e0160b618cb30bb05105af9b5--