zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: "{ } always { }" construct and return in called functions
Date: Mon, 18 May 2015 13:38:15 +0200	[thread overview]
Message-ID: <CAHYJk3RBn_U_ZTNXWHeBfAJyibspcx1=gMM2OTmXz2cpsrrY2Q@mail.gmail.com> (raw)
In-Reply-To: <20150513155915.71f3daaa@pwslap01u.europe.root.pri>

On Wed, May 13, 2015 at 4:59 PM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Wed, 13 May 2015 14:31:41 +0200
> ia0 <zsh@ia0.eu> wrote:
>> There is something I don't understand with the "{ } always { }" construct.
>> What is the difference between the two following runs? I would expect the
>> last run to behave as the first one. What am I missing here?
>>
>> *% zsh --version*
>> zsh 5.0.2 (x86_64-pc-linux-gnu)
>> *% cat test*
>> #!/bin/zsh
>>
>> mytrue() { return 0 }
>> mywrap() { echo BEGIN; $1; echo END }
>> mytest() { { exit 1 } always { mywrap $1 } }
>>
>> mytest $1
>> *% ./test true*
>> BEGIN
>> END
>> *1% ./test mytrue*
>> BEGIN
>> *1% *
>
> Nested functions in always blocks with an exit pending are a corner case
> that needs fixing.  I'm not sure if this affects exit traps for
> functions, but possibly only in even weirder cases.
>
> Follow-ups can go to zsh-workers --- there are no user-serviceable
> parts inside.

This patch breaks my setup.

# Some hooks into accept-line
if [[ -n "$ZSHRUN" ]]; then
  unsetopt correct
  function _accept_and_quit() {
  local -a buf
  buf=(${(z)BUFFER})
  if which $buf[1] >& /dev/null; then
    zsh -c "${BUFFER}" &|
    exit
  else
    zle -M "Command $buf[1] not found"
  fi
  }
  zle -N _accept_and_quit
  bindkey "^M" _accept_and_quit
fi

With the patch, commands are randomly ran two or three times instead
of just once in the background. AFAIK there are no always blocks
involved in this part of my rc.

-- 
Mikael Magnusson


       reply	other threads:[~2015-05-18 11:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAHfspHmUOgLjnEMtLBBoeU31Z2GKu8uD5MYE4jsogMKbf+ag9g@mail.gmail.com>
     [not found] ` <20150513155915.71f3daaa@pwslap01u.europe.root.pri>
2015-05-18 11:38   ` Mikael Magnusson [this message]
2015-05-18 12:14     ` Peter Stephenson
2015-05-18 12:24       ` Mikael Magnusson
2015-05-18 12:47         ` Peter Stephenson
2015-05-19  5:04           ` Bart Schaefer
2015-05-19  6:22             ` Mikael Magnusson
2015-05-19  6:31               ` Mikael Magnusson
2015-05-20 17:31               ` Bart Schaefer
2015-05-22 22:31     ` Peter Stephenson
2015-05-22 22:46       ` Bart Schaefer
2015-05-23 10:49       ` Daniel Shahaf
2015-05-23 15:13       ` Mikael Magnusson
2015-05-27  2:20         ` Dave Yost
2015-05-30  0:31           ` Bang-four (Re: "{ } always { }" construct and return in called functions) Bart Schaefer
2015-05-23 22:32       ` Release blocker (was: " Daniel Hahler
2015-05-24 12:54         ` Peter Stephenson
2015-05-26  9:03           ` Peter Stephenson

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='CAHYJk3RBn_U_ZTNXWHeBfAJyibspcx1=gMM2OTmXz2cpsrrY2Q@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=p.stephenson@samsung.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).