* [PATCH] "emulate" accidentally allows "--version" and "--help"
@ 2017-04-15 23:20 Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2017-04-15 23:20 UTC (permalink / raw)
To: zsh-workers
Because it shares option parsing code with shell startup, it is possible
to run "emulate zsh --version" or "emulate ksh --help" and so on. The
result is unexpected and usually inaccurate given the context, and also
confuses other option parsing, so it's probably best to disallow it.
diff --git a/Src/init.c b/Src/init.c
index a1162b3..d8c26ac 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -376,12 +376,12 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp,
*argv = "--";
while (*++*argv) {
if (**argv == '-') {
- if(!argv[0][1]) {
+ if (!argv[0][1]) {
/* The pseudo-option `--' signifies the end of options. */
argv++;
goto doneoptions;
}
- if(*argv != args+1 || **argv != '-')
+ if (nam || *argv != args+1 || **argv != '-')
goto badoptionstring;
/* GNU-style long options */
++*argv;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-04-15 23:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-15 23:20 [PATCH] "emulate" accidentally allows "--version" and "--help" Bart Schaefer
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).