zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: parse vs. runtime errors
Date: Fri, 20 Apr 2018 18:48:56 -0700	[thread overview]
Message-ID: <19541cbf-809a-4809-b5ed-a9969e90d1d9@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7Y2HTXN13EWgZGBmPjtUJo8caxOov2PzpY51NvrLOUMjg@mail.gmail.com>

On 20/04/18 12:00 PM, Bart Schaefer wrote:
> On Fri, Apr 20, 2018, 11:31 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
>
> "[" is a command (synonym for "test") and not a token, and "]]" is only a
> token when balanced with "[[".
Probably way over my head.  I expect the former goes back to the 
beginning of shells so is written in stone.  The latter seems 
'obviously' strange so  I expect there's a good reason for it, but it 
sure is counter intuitive.  Still, why/how can it be acceptable at parse 
but not at run?  Perhaps because it is theoretically 
completeable/resolvable at parse but in practice turns out to be a dead 
end at run?  That is, one might write something that ends up with that 
construction not being an error? at runtime?
>
> That's what "setopt errexit" is for, although that mostly applies to
> scripts rather than interactive shells.
>
Yeah, no luck:

test1 ()
{

setopt errexit
[ "$1" = 'two' ]] && echo that was two
echo that was three

}

16 /aWorking/Zsh/Source/Wk 3 $ . test

16 /aWorking/Zsh/Source/Wk 3 $ test1 two
test1:[:4: ']' expected
that was three

... so it didn't abort the function.  Any other way?



      reply	other threads:[~2018-04-21  1:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 18:00 Ray Andrews
2018-04-20 19:00 ` Bart Schaefer
2018-04-21  1:48   ` Ray Andrews [this message]

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=19541cbf-809a-4809-b5ed-a9969e90d1d9@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).