Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] "emulate" accidentally allows "--version" and "--help"
- X-seq: zsh-workers 40977
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] "emulate" accidentally allows "--version" and "--help"
- Date: Sat, 15 Apr 2017 16:20:25 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:to:subject:mime-version; bh=ViN2fvPVPE5znI+bK4AG18AKgi+24e2yhQzDKJ3NSE8=; b=IKXo6mP/tYAYhLQek7sIK+ct+fG8Qqkt9SI9rDMbUU9P1Q+guD1YtUmwprKhImV1Ka xYHioGgP3ols1UiPRsr7N+ljFm/kD44Ug9sXKlovoI9x2TXnZRwf6U3xbTiMa+4PevqF jw/+HQhiJZ31f6Cgf1vh92606TsCm/MiGaoHzIRxER3I8v0+X/0GjYVRJcHuvc/KMOa3 4aLzK1GBXuoNYZp/83FF+yXwMHlr2NiNSorTijMSz4NMOpqU35XST1qfxlDpJJQpUcSS DBPyGXcHDEB8LxsRF+nwdk0EZBZI+yvjqk8gCsbNJV3wskRVLggDu7XdgnXWAea2FAOV Bsxw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author