mirror of https://github.com/mirror/busybox.git
ash: support "--" in "source" builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>1_26_stable
parent
0aaaa50b45
commit
0cdb7ea380
30
shell/ash.c
30
shell/ash.c
|
@ -12405,32 +12405,38 @@ find_dot_file(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int FAST_FUNC
|
static int FAST_FUNC
|
||||||
dotcmd(int argc, char **argv)
|
dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM)
|
||||||
{
|
{
|
||||||
|
/* "false; . empty_file; echo $?" should print 0, not 1: */
|
||||||
|
int status = 0;
|
||||||
char *fullname;
|
char *fullname;
|
||||||
|
char **argv;
|
||||||
struct strlist *sp;
|
struct strlist *sp;
|
||||||
volatile struct shparam saveparam;
|
volatile struct shparam saveparam;
|
||||||
|
|
||||||
for (sp = cmdenviron; sp; sp = sp->next)
|
for (sp = cmdenviron; sp; sp = sp->next)
|
||||||
setvareq(ckstrdup(sp->text), VSTRFIXED | VTEXTFIXED);
|
setvareq(ckstrdup(sp->text), VSTRFIXED | VTEXTFIXED);
|
||||||
|
|
||||||
if (!argv[1]) {
|
nextopt(nullstr); /* handle possible "--" */
|
||||||
|
argv = argptr;
|
||||||
|
|
||||||
|
if (!argv[0]) {
|
||||||
/* bash says: "bash: .: filename argument required" */
|
/* bash says: "bash: .: filename argument required" */
|
||||||
return 2; /* bash compat */
|
return 2; /* bash compat */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "false; . empty_file; echo $?" should print 0, not 1: */
|
|
||||||
exitstatus = 0;
|
|
||||||
|
|
||||||
/* This aborts if file isn't found, which is POSIXly correct.
|
/* This aborts if file isn't found, which is POSIXly correct.
|
||||||
* bash returns exitcode 1 instead.
|
* bash returns exitcode 1 instead.
|
||||||
*/
|
*/
|
||||||
fullname = find_dot_file(argv[1]);
|
fullname = find_dot_file(argv[0]);
|
||||||
argv += 2;
|
argv++;
|
||||||
argc -= 2;
|
if (argv[0]) { /* . FILE ARGS, ARGS exist */
|
||||||
if (argc) { /* argc > 0, argv[0] != NULL */
|
int argc;
|
||||||
saveparam = shellparam;
|
saveparam = shellparam;
|
||||||
shellparam.malloced = 0;
|
shellparam.malloced = 0;
|
||||||
|
argc = 1;
|
||||||
|
while (argv[argc])
|
||||||
|
argc++;
|
||||||
shellparam.nparam = argc;
|
shellparam.nparam = argc;
|
||||||
shellparam.p = argv;
|
shellparam.p = argv;
|
||||||
};
|
};
|
||||||
|
@ -12440,15 +12446,15 @@ dotcmd(int argc, char **argv)
|
||||||
*/
|
*/
|
||||||
setinputfile(fullname, INPUT_PUSH_FILE);
|
setinputfile(fullname, INPUT_PUSH_FILE);
|
||||||
commandname = fullname;
|
commandname = fullname;
|
||||||
cmdloop(0);
|
status = cmdloop(0);
|
||||||
popfile();
|
popfile();
|
||||||
|
|
||||||
if (argc) {
|
if (argv[0]) {
|
||||||
freeparam(&shellparam);
|
freeparam(&shellparam);
|
||||||
shellparam = saveparam;
|
shellparam = saveparam;
|
||||||
};
|
};
|
||||||
|
|
||||||
return exitstatus;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int FAST_FUNC
|
static int FAST_FUNC
|
||||||
|
|
Loading…
Reference in New Issue