From: Richard Hansen <rhansen@bbn.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers@zsh.org
Subject: Re: 'emulate sh -c' and $0
Date: Tue, 03 Jun 2014 16:15:25 -0400 [thread overview]
Message-ID: <538E2CDD.7070106@bbn.com> (raw)
In-Reply-To: <140530221301.ZM31798@torch.brasslantern.com>
On 2014-05-31 01:13, Bart Schaefer wrote:
> If we leave FUNCTION_ARGZERO as it is (that is, off by default for sh
> emulation) and add an option POSIX_ARGZERO which exposes the global
> argzero when set (inverting your Option #2) but which is never on by
> default, then bin_emulate can set POSIX_ARGZERO in the -c scope when
> emulating sh/ksh, and it will be sticky for functions defined there.
>
> We wouldn't even have to build those smarts into bin_emulate; a user
> who wanted the POSIX semantics could explicitly do
>
> emulate sh -o POSIX_ARGZERO -c '...'
>
> The only "magic" necessary is that POSIX_ARGZERO exposes the original
> value of $0 in spite of the current FUNCTION_ARGZERO setting.
>
> Here are the bits outside bin_emulate, and not yet with doc. I suppose
> there may be some places where posixzero needs to be saved / changed /
> restored, which this hasn't covered.
Wow, thank you for committing this change to master! It works well in
my limited testing, except for the documented limitation that
POSIX_ARGZERO stays enabled when calling a non-emulated function from a
function defined in 'emulate <shell> -c'. I'm not sure how much this
will matter in practice, but if backward compatibility wasn't a concern
it'd be nice if zsh temporarily restored options when invoking a
function outside the 'emulate <shell> -c' boundary.
Although it would be a behavior change, I think it would be best if both
'emulate sh' and 'emulate sh -c' set POSIX_ARGZERO by default: I
suspect that someone who runs 'emulate sh' cares more about accurate sh
emulation than compatibility with previous sh emulation behavior. :)
Thanks,
Richard
next prev parent reply other threads:[~2014-06-03 20:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 23:04 Richard Hansen
2014-05-30 3:45 ` Bart Schaefer
2014-05-30 8:49 ` Richard Hansen
2014-05-30 17:00 ` Bart Schaefer
2014-05-30 21:14 ` Richard Hansen
2014-05-31 5:13 ` Bart Schaefer
2014-05-31 23:47 ` Bart Schaefer
2014-06-03 20:15 ` Richard Hansen [this message]
2014-06-03 20:26 ` Peter Stephenson
2014-06-03 21:10 ` Bart Schaefer
2014-06-03 23:35 ` Richard Hansen
2014-06-04 0:09 ` Bart Schaefer
2014-06-03 21:21 ` Bart Schaefer
2014-06-03 22:54 ` Richard Hansen
2014-06-04 0:03 ` Bart Schaefer
2014-06-04 1:10 ` Bart Schaefer
2014-06-04 1:23 ` Bart Schaefer
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=538E2CDD.7070106@bbn.com \
--to=rhansen@bbn.com \
--cc=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).