aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 94aabbc4c..aa291b99d 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -9104,14 +9104,9 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
9104 /* mingw-w64's getopt() uses __argv[0] as the program name */ 9104 /* mingw-w64's getopt() uses __argv[0] as the program name */
9105 __argv[0] = (char *)cmd; 9105 __argv[0] = (char *)cmd;
9106 /* 'which' wants to know if it was invoked from a standalone 9106 /* 'which' wants to know if it was invoked from a standalone
9107 * shell. Use the spare element of argv to add a flag, but 9107 * shell. 'Which' in argv[0] indicates this. */
9108 * not if the first argument is '--help', that's a special 9108 if (strcmp(argv[0], "which") == 0) {
9109 * case. */ 9109 argv[0] = (char *)"Which";
9110 if (strcmp(argv[0], "which") == 0 &&
9111 (argv[1] == NULL || strcmp(argv[1], "--help") != 0)) {
9112 --argv;
9113 argv[0] = argv[1];
9114 argv[1] = (char *)"-s";
9115 } 9110 }
9116# else 9111# else
9117 if (APPLET_IS_NOEXEC(applet_no)) { 9112 if (APPLET_IS_NOEXEC(applet_no)) {
@@ -11585,9 +11580,13 @@ evalcommand(union node *cmd, int flags)
11585 11580
11586 localvar_stop = pushlocalvars(vlocal); 11581 localvar_stop = pushlocalvars(vlocal);
11587 11582
11583#if ENABLE_PLATFORM_MINGW32
11584 argv = nargv = stalloc(sizeof(char *) * (argc + 1));
11585#else
11588 /* Reserve one extra spot at the front for shellexec. */ 11586 /* Reserve one extra spot at the front for shellexec. */
11589 nargv = stalloc(sizeof(char *) * (argc + 2)); 11587 nargv = stalloc(sizeof(char *) * (argc + 2));
11590 argv = ++nargv; 11588 argv = ++nargv;
11589#endif
11591 for (sp = arglist.list; sp; sp = sp->next) { 11590 for (sp = arglist.list; sp; sp = sp->next) {
11592 TRACE(("evalcommand arg: %s\n", sp->text)); 11591 TRACE(("evalcommand arg: %s\n", sp->text));
11593 *nargv++ = sp->text; 11592 *nargv++ = sp->text;
@@ -16791,8 +16790,7 @@ argv_size(struct datasize ds, char **p)
16791 ds.funcstringsize += align_len(*p); 16790 ds.funcstringsize += align_len(*p);
16792 p++; 16791 p++;
16793 } 16792 }
16794 // Allow for argv[-1] used by tryexec(). 16793 ds.funcblocksize += sizeof(char *);
16795 ds.funcblocksize += 2 * sizeof(char *);
16796 } 16794 }
16797 return ds; 16795 return ds;
16798} 16796}
@@ -16806,8 +16804,6 @@ argv_copy(char **p)
16806#endif 16804#endif
16807 16805
16808 if (p) { 16806 if (p) {
16809 // argv[-1] for tryexec()
16810 funcblock = (char *) funcblock + sizeof(char *);
16811 while (*p) { 16807 while (*p) {
16812 new = funcblock; 16808 new = funcblock;
16813 funcblock = (char *) funcblock + sizeof(char *); 16809 funcblock = (char *) funcblock + sizeof(char *);
@@ -16818,7 +16814,7 @@ argv_copy(char **p)
16818 new = funcblock; 16814 new = funcblock;
16819 funcblock = (char *) funcblock + sizeof(char *); 16815 funcblock = (char *) funcblock + sizeof(char *);
16820 *new = NULL; 16816 *new = NULL;
16821 return start + 1; 16817 return start;
16822 } 16818 }
16823 return NULL; 16819 return NULL;
16824} 16820}