From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: grammar triviality with '&&'
Date: Fri, 06 Mar 2015 08:10:40 -0800 [thread overview]
Message-ID: <54F9D180.4020900@eastlink.ca> (raw)
In-Reply-To: <150305205951.ZM8811@torch.brasslantern.com>
On 03/05/2015 08:59 PM, Bart Schaefer wrote:
> On Mar 4, 9:12am, Ray Andrews wrote:
> }
> } If an extra degree of freedom and capability was possible, and IF it
> } could be implemented with no gotchas, then why not?
>
> Because we don't need the grammar to become any more ad-hoc than it
> already has?
A quite sufficient reason. My very unlearned sense of it was that the
errorlevel
test is implicit in any '&&' anyway, and since that test wraps 'down'
legally
already, then it would be trivially simple to understand that that same
value is
grabbed when '&&' starts a line. I was liking Vincent's thinking.
Or not! It seemed to me like a relaxation of
something arbitrary. However if it really would be add-hoc then of
course it
can't be touched. Please recall that this is a *question*.
>
> Back in the depths of time, one of the reasons zsh was invented was
> because csh's grammar was too irregular. Csh scripts originally (I
> can't speak for how tcsh &c. may be now) could in fact be interpreted
> one line at a time, and literally were: "while" loop was processed by
> remembering the file position of the string "while" and then when the
> "end" was encountered, seeking back and re-reading the lines again.
> This made it possible to write some really entertaining scripts that
> edited their own code on the fly, but made it impossible to syntax
> check a multi-line control structure before beginning to execute it.
God forbid.
>
> The Bourne-shell / POSIX shell grammar is at least regular enough to
> be parsed before it is executed, even with all its other warts.
> Introducing a case where the command to the left of && / || can be
> empty if and only if the conjunction is the first token on a line, is
> the kind of irregularity that should be avoided.
>
> Further, in the standard definition of the grammar where pipelines
> separated by && or || form a sublist, the terminator that follows is
> syntactically significant to the whole sublist. That is:
>
> one && two || three &
>
> is parsed as
>
> { one && two || three } &
>
> which is not the same as
>
> one ; [[ $? = 0 ]] && two ; [[ $? = 0 ]] || three &
Well that kills my notion that it's implicit, I thought the latter was
what was really going
on in any case. Dare a mortal ask what the difference is between those?
The deeper
question is why shells were designed this way. In C this sort of
obscurity not only
doesn't exist, it couldn't exist, you can wrap code anyway you want
(string printing
excepted). But shells are written in C, yet the decision was made to
make things
so convoluted that no one fully understands them. This work was done by
geniuses so
there musta been a good reason.
next prev parent reply other threads:[~2015-03-06 16:10 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
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 [this message]
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=54F9D180.4020900@eastlink.ca \
--to=rayandrews@eastlink.ca \
--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).