From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-users@zsh.org
Subject: Re: grammar triviality with '&&'
Date: Mon, 2 Mar 2015 11:46:19 +0100 [thread overview]
Message-ID: <20150302104619.GC6869@xvii.vinc17.org> (raw)
In-Reply-To: <CABx2=D8efL3X2tfB+_+VweY2yye6EhaMNbJa3b3jJeVMp=7gaQ@mail.gmail.com>
On 2015-03-01 19:53:28 -0800, Kurtis Rader wrote:
> On Sun, Mar 1, 2015 at 6:27 PM, Vincent Lefevre <vincent@vinc17.net> 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 <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
next prev parent reply other threads:[~2015-03-02 10:46 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-01 16:07 Ray Andrews
2015-03-01 16:43 ` ZyX
2015-03-01 17:01 ` Ray Andrews
2015-03-01 18:48 ` Bart Schaefer
2015-03-01 19:00 ` ZyX
2015-03-01 19:16 ` Ray Andrews
2015-03-01 20:48 ` ZyX
2015-03-01 18:49 ` Lawrence Velázquez
2015-03-02 2:27 ` Vincent Lefevre
2015-03-02 3:12 ` Ray Andrews
2015-03-02 5:22 ` Lawrence Velázquez
2015-03-02 3:53 ` Kurtis Rader
2015-03-02 4:18 ` Ray Andrews
2015-03-02 5:22 ` Kurtis Rader
2015-03-02 16:17 ` Ray Andrews
2015-03-02 18:52 ` Kurtis Rader
2015-03-02 19:03 ` ZyX
2015-03-02 20:16 ` Kurtis Rader
2015-03-03 4:15 ` ZyX
2015-03-03 4:43 ` Kurtis Rader
2015-03-04 15:03 ` Vincent Lefevre
2015-03-04 19:07 ` ZyX
2015-03-02 19:25 ` Ray Andrews
2015-03-02 10:46 ` Vincent Lefevre [this message]
2015-03-02 11:06 ` Peter Stephenson
2015-03-02 19:19 ` Bart Schaefer
2015-03-04 14:47 ` Vincent Lefevre
2015-03-05 1:51 ` Bart Schaefer
2015-03-05 10:06 ` Peter Stephenson
2015-03-02 8:54 ` Bart Schaefer
2015-03-02 10:31 ` Vincent Lefevre
2015-03-02 16:31 ` Ray Andrews
2015-03-02 16:49 ` Bart Schaefer
2015-03-02 17:38 ` Ray Andrews
2015-03-02 18:51 ` Bart Schaefer
2015-03-04 8:55 ` Vincent Lefevre
2015-03-04 17:12 ` Ray Andrews
2015-03-06 4:59 ` Bart Schaefer
2015-03-06 16:10 ` Ray Andrews
2015-03-06 20:23 ` Lawrence Velázquez
2015-03-06 21:25 ` Ray Andrews
2015-03-06 16:32 ` Vincent Lefevre
2015-03-06 17:43 ` Bart Schaefer
2015-03-06 21:01 ` Ray Andrews
2015-03-09 11:26 ` Vincent Lefevre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150302104619.GC6869@xvii.vinc17.org \
--to=vincent@vinc17.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).