zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: "var=value exec > file" ignores the assignment?
Date: Wed, 8 Apr 2015 10:13:02 -0700	[thread overview]
Message-ID: <150408101302.ZM23667@torch.brasslantern.com> (raw)
In-Reply-To: <3D84EC4C-3267-4567-8642-B4F86AB93610@kba.biglobe.ne.jp>

On Apr 8, 12:51am, Jun T. wrote:
}
} If 'exec' has no command arg but has both parameter assignment
} and redirection, the assignment seems to be ignored.

Hm.  This probably comes down to the behavior of "special" built-ins
which are supposed to retain the results of environment assignments.
It's possible (likely?) your patch should add a POSIX_BUILTINS test.

I'm not sure why we skip the XTRACE when nullexec == 1.  If your patch
is otherwise correct, there doesn't seem to be any other reason to
distinguish the 1 and 2 cases.

} Either with or without the patch, and either POSIX_BUILTINS is
} set or unset, the following outputs "x = 1" (/bin/sh outputs
} "x = 0"). But I don't know whether this need be fixed (or how
} to fix it if it need be).
} 
} x=0
} true | x=1 exec | true
} echo "x = $x"

This is a curious one.  Normally zsh would fork off "x=1 exec" so the
assignment would only affect a subshell, but that is apparently short-
circuited because the subshell has nothing else to do.  This:

x=0
true | x=1 | true

also assigns so $x == 1 whereas this:

true | { x=1 } | true

which should otherwise be equivalent, leaves $x == 0.  Anyway the point
is I don't think the presence of "exec" has anything to do with this
particular behavior.


  reply	other threads:[~2015-04-08 17:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 15:51 Jun T.
2015-04-08 17:13 ` Bart Schaefer [this message]
2015-04-09 16:13   ` Jun T.
2015-04-15 19:52     ` Peter Stephenson
2015-04-15 20:27       ` 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=150408101302.ZM23667@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).