From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29277 invoked by alias); 2 Mar 2015 10:46:23 -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: 19952 Received: (qmail 22044 invoked from network); 2 Mar 2015 10:46:21 -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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_PCNT autolearn=no version=3.3.2 Date: Mon, 2 Mar 2015 11:46:19 +0100 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: grammar triviality with '&&' Message-ID: <20150302104619.GC6869@xvii.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <54F33934.2070607@eastlink.ca> <13666281425228233@web7o.yandex.ru> <54F345D3.9010204@eastlink.ca> <20150302022754.GA7449@xvii.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.23-6424-vl-r76280 (2015-02-19) On 2015-03-01 19:53:28 -0800, Kurtis Rader wrote: > On Sun, Mar 1, 2015 at 6:27 PM, Vincent Lefevre wrote: > > > However "&& [ -e file2 ]" could constitute a list too. There is > > currently a parse error, but zsh could have an extension to accept > > it as being equivalent to: "[[ $? -eq 0 ]] && [ -e file2 ]". Would > > there be anything wrong with such an extension? > > > > Similarly, "|| X" could be regarded as equivalent to > > "[[ $? -ne 0 ]] || X" by zsh. > > > > How often would such a feature be useful? Very infrequently in my opinion. I'm not so sure. It's probably useless in a script (except for the style as in the original post, but this may not be a good idea to use such a feature here). But I can see an interesting use in an interactive shell when using the history. For instance, one may want to run 3 (long) commands from time to time, by using the history and accept-line-and-down-history: cmd1 cmd2 cmd3 Now, assume that as soon as some command fails, you don't want to execute the following ones, but you still want to have the 3 commands in the history when invoking the latest cmd1 by a history search (something I often do). Currently, the only way to do that is, AFAIK: cmd1 [[ $? -eq 0 ]] && cmd2 [[ $? -eq 0 ]] && cmd3 But having cmd1 && cmd2 && cmd3 could be nicer (I would also like the fact that one can easier see that these 3 commands are related). Of course, one could also do: cmd1 && cmd2 && cmd3 but if the commands produce output, one may prefer to run them separately to analyze the output first (which is the main goal of interactive use vs writing a script). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)