zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Vasiliy Ivanov <beelzebubbie.logs@gmail.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: `=' expansion causes script/subshell to exit, bug?
Date: Fri, 28 Sep 2018 00:38:15 +0200	[thread overview]
Message-ID: <CAHYJk3QHUuxLXjot7mdy-Bo_HJ5u07Ex5=zspT6P7eyzfXc5AA@mail.gmail.com> (raw)
In-Reply-To: <16141d86-9d3e-275f-f7b4-d8b07fc97aa7@gmail.com>

On Thu, Sep 27, 2018 at 9:20 PM, Vasiliy Ivanov
<beelzebubbie.logs@gmail.com> wrote:
> Hello. Recently I've seen that line like
>
> [[ -x =somebinary ]] || cmd
>
> causes script to exit unexpectedly with message like «/path/to/script:$line: =somebinary not found»,
> instead of invoking || cmd and continue executing
>
> some simple tests:
>
> % ( [[ -x =123123 ]] || { print 'ohshi'; exit 2 } )
> zsh: 123123 not found <exit code 1>
>
> % ( b=123123; print =$b; print 'ohshi' )                                                  ↑
> zsh: 123123 not found
>
> Is it intended behaviour?
>
> % zsh --version
> zsh 5.6.2 (x86_64-pc-linux-gnu)

If you don't want to change any options, you can also use this
construct to avoid exiting without a subshell,

% { [[ -x =somebinary ]] } always { TRY_BLOCK_ERROR=0 } || echo hey
zsh: somebinary not found
hey

I also have this in my .zshrc
alias always_continue='always { TRY_BLOCK_ERROR=0 }'
so I can do just
% { [[ -x =somebinary ]] } always_continue || echo hey
zsh: somebinary not found
hey

-- 
Mikael Magnusson

      parent reply	other threads:[~2018-09-27 22:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27 19:20 Vasiliy Ivanov
2018-09-27 19:41 ` dana
2018-09-27 20:33   ` Bart Schaefer
2018-09-27 20:37     ` dana
2018-09-27 22:38 ` Mikael Magnusson [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='CAHYJk3QHUuxLXjot7mdy-Bo_HJ5u07Ex5=zspT6P7eyzfXc5AA@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=beelzebubbie.logs@gmail.com \
    --cc=zsh-workers@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).