From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Is this a bug in "emulate"? And is this the right fix?
Date: Thu, 20 Aug 2015 20:59:04 -0700 [thread overview]
Message-ID: <150820205904.ZM29615@torch.brasslantern.com> (raw)
The syntax is
emulate [ -LR ] [ {zsh|sh|ksh|csh} [ FLAGS ... ] ]
where FLAGS are any of the usual things you can pass to "set". There is
a notation:
The -L switch is mutually exclusive with the use of -c in FLAGS.
In fact it appears the -L switch is mutually incompatible with any FLAGS
at all:
torch% diff =(emulate -L sh ; set -o) =(emulate -L sh -e ; set -o)
50c50
< errexit off
---
> errexit on
106,108c106,108
< localoptions on
< localpatterns on
< localtraps on
---
> localoptions off
> localpatterns off
> localtraps off
I would have expected the only difference to be errexit on/off.
diff --git a/Src/builtin.c b/Src/builtin.c
index 572a0dd..6411faa 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5465,8 +5465,8 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func))
/* with single argument set current emulation */
if (!argv[1]) {
- emulate(shname, OPT_ISSET(ops,'R'), &emulation, opts);
- if (OPT_ISSET(ops,'L'))
+ emulate(shname, opt_R, &emulation, opts);
+ if (opt_L)
opts[LOCALOPTIONS] = opts[LOCALTRAPS] = opts[LOCALPATTERNS] = 1;
clearpatterndisables();
return 0;
@@ -5476,7 +5476,7 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func))
memcpy(saveopts, opts, sizeof(opts));
memcpy(new_opts, opts, sizeof(opts));
savehackchar = keyboardhackchar;
- emulate(shname, OPT_ISSET(ops,'R'), &new_emulation, new_opts);
+ emulate(shname, opt_R, &new_emulation, new_opts);
optlist = newlinklist();
if (parseopts("emulate", &argv, new_opts, &cmd, optlist)) {
ret = 1;
@@ -5508,8 +5508,11 @@ bin_emulate(UNUSED(char *nam), char **argv, Options ops, UNUSED(int func))
goto restore2;
}
*--argv = cmd; /* on stack, never free()d, see execbuiltin() */
- } else
+ } else {
+ if (opt_L)
+ opts[LOCALOPTIONS] = opts[LOCALTRAPS] = opts[LOCALPATTERNS] = 1;
return 0;
+ }
save_sticky = sticky;
sticky = hcalloc(sizeof(*sticky));
--
Barton E. Schaefer
reply other threads:[~2015-08-21 3:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=150820205904.ZM29615@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).