After bug report 262 (from 2010)
https://austingroupbugs.net/view.php?id=252 the Austin Group decided to require processing of "--" by the "." and "exec" commands to solve a problem where some shells did option processing for those commands (permitted) and others did not (also permitted) which left no safe way to process a file with a name beginning with "-". This has finally made its way into what will be the next version of the POSIX standard. Since this shell did no option processing at all for those commands, we need to update. This is that update. The sole effect is that a "--" 'option' (to "." or "exec") is ignored. This means that if you want to use "--" as the arg to one of those commands, it needs to be given twice ". -- --". Apart from that there should be no difference at all (though the "--" can now be used in other situations, where we did not require it before, and still do not).
This commit is contained in:
parent
9f8ca85981
commit
ebc4cf1cc6
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: eval.c,v 1.177 2019/12/21 18:54:15 kre Exp $ */
|
||||
/* $NetBSD: eval.c,v 1.178 2020/02/04 16:06:59 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: eval.c,v 1.177 2019/12/21 18:54:15 kre Exp $");
|
||||
__RCSID("$NetBSD: eval.c,v 1.178 2020/02/04 16:06:59 kre Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -1493,7 +1493,9 @@ dotcmd(int argc, char **argv)
|
||||
{
|
||||
exitstatus = 0;
|
||||
|
||||
if (argc >= 2) { /* That's what SVR2 does */
|
||||
(void) nextopt(NULL); /* ignore a leading "--" */
|
||||
|
||||
if (*argptr != NULL) { /* That's what SVR2 does */
|
||||
char *fullname;
|
||||
/*
|
||||
* dot_funcnest needs to be 0 when not in a dotcmd, so it
|
||||
@ -1503,7 +1505,7 @@ dotcmd(int argc, char **argv)
|
||||
struct stackmark smark;
|
||||
|
||||
setstackmark(&smark);
|
||||
fullname = find_dot_file(argv[1]);
|
||||
fullname = find_dot_file(*argptr);
|
||||
setinputfile(fullname, 1);
|
||||
commandname = fullname;
|
||||
dot_funcnest_old = dot_funcnest;
|
||||
@ -1649,7 +1651,9 @@ truecmd(int argc, char **argv)
|
||||
int
|
||||
execcmd(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1) {
|
||||
(void) nextopt(NULL); /* ignore a leading "--" */
|
||||
|
||||
if (*argptr) {
|
||||
struct strlist *sp;
|
||||
|
||||
iflag = 0; /* exit on error */
|
||||
@ -1657,7 +1661,7 @@ execcmd(int argc, char **argv)
|
||||
optschanged();
|
||||
for (sp = cmdenviron; sp; sp = sp->next)
|
||||
setvareq(sp->text, VDOEXPORT|VEXPORT|VSTACK);
|
||||
shellexec(argv + 1, environment(), pathval(), 0, 0);
|
||||
shellexec(argptr, environment(), pathval(), 0, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: options.c,v 1.53 2018/07/13 22:43:44 kre Exp $ */
|
||||
/* $NetBSD: options.c,v 1.54 2020/02/04 16:06:59 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: options.c,v 1.53 2018/07/13 22:43:44 kre Exp $");
|
||||
__RCSID("$NetBSD: options.c,v 1.54 2020/02/04 16:06:59 kre Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -595,7 +595,11 @@ out:
|
||||
* Standard option processing (a la getopt) for builtin routines. The
|
||||
* only argument that is passed to nextopt is the option string; the
|
||||
* other arguments are unnecessary. It return the character, or '\0' on
|
||||
* end of input.
|
||||
* end of input. If optstring is NULL, then there are no options, and
|
||||
* args are allowed to begin with '-', but a single leading "--" will be
|
||||
* discarded. This is for some POSIX special builtins that require
|
||||
* -- processing, have no args, and we never did opt processing before
|
||||
* and need to retain backwards compat.
|
||||
*/
|
||||
|
||||
int
|
||||
@ -613,6 +617,8 @@ nextopt(const char *optstring)
|
||||
if (p[0] == '-' && p[1] == '\0') /* check for "--" */
|
||||
return '\0';
|
||||
}
|
||||
if (optstring == NULL)
|
||||
return '\0';
|
||||
c = *p++;
|
||||
for (q = optstring ; *q != c ; ) {
|
||||
if (*q == '\0')
|
||||
|
Loading…
x
Reference in New Issue
Block a user