aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-14 11:33:10 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-14 11:33:10 +0000
commit8fdc4b7b06ada63a2572f8aff92e8810e52ae841 (patch)
tree5e4c13a621c5e7bde70e8cc37d3e7f2fed9cd33c
parent40ba9984fd363cfceb2f7f10a882ade282a195aa (diff)
downloadbusybox-w32-8fdc4b7b06ada63a2572f8aff92e8810e52ae841.tar.gz
busybox-w32-8fdc4b7b06ada63a2572f8aff92e8810e52ae841.tar.bz2
busybox-w32-8fdc4b7b06ada63a2572f8aff92e8810e52ae841.zip
ash: recognize -l as --login equivalent; do not recognize +-login
-rw-r--r--shell/ash.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/shell/ash.c b/shell/ash.c
index bf0fd656b..ccb1e1a58 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -134,7 +134,6 @@ static const char illnum[] = "Illegal number: %s";
134 134
135static char *minusc; /* argument to -c option */ 135static char *minusc; /* argument to -c option */
136 136
137static int isloginsh;
138/* pid of main shell */ 137/* pid of main shell */
139static int rootpid; 138static int rootpid;
140/* shell level: 0 for the main shell, 1 for its children, and so on */ 139/* shell level: 0 for the main shell, 1 for its children, and so on */
@@ -142,6 +141,7 @@ static int shlvl;
142#define rootshell (!shlvl) 141#define rootshell (!shlvl)
143/* trap handler commands */ 142/* trap handler commands */
144static char *trap[NSIG]; 143static char *trap[NSIG];
144static smallint isloginsh;
145/* current value of signal */ 145/* current value of signal */
146static char sigmode[NSIG - 1]; 146static char sigmode[NSIG - 1];
147/* indicates specified signal received */ 147/* indicates specified signal received */
@@ -9027,8 +9027,11 @@ options(int cmdline)
9027 if (cmdline) 9027 if (cmdline)
9028 minusc = NULL; 9028 minusc = NULL;
9029 while ((p = *argptr) != NULL) { 9029 while ((p = *argptr) != NULL) {
9030 argptr++;
9031 c = *p++; 9030 c = *p++;
9031 if (c != '-' && c != '+')
9032 break;
9033 argptr++;
9034 val = 0; /* val = 0 if c == '+' */
9032 if (c == '-') { 9035 if (c == '-') {
9033 val = 1; 9036 val = 1;
9034 if (p[0] == '\0' || LONE_DASH(p)) { 9037 if (p[0] == '\0' || LONE_DASH(p)) {
@@ -9042,20 +9045,20 @@ options(int cmdline)
9042 } 9045 }
9043 break; /* "-" or "--" terminates options */ 9046 break; /* "-" or "--" terminates options */
9044 } 9047 }
9045 } else if (c == '+') {
9046 val = 0;
9047 } else {
9048 argptr--;
9049 break;
9050 } 9048 }
9049 /* first char was + or - */
9051 while ((c = *p++) != '\0') { 9050 while ((c = *p++) != '\0') {
9051 /* bash 3.2 indeed handles -c CMD and +c CMD the same */
9052 if (c == 'c' && cmdline) { 9052 if (c == 'c' && cmdline) {
9053 minusc = p; /* command is after shell args*/ 9053 minusc = p; /* command is after shell args */
9054 } else if (c == 'o') { 9054 } else if (c == 'o') {
9055 minus_o(*argptr, val); 9055 minus_o(*argptr, val);
9056 if (*argptr) 9056 if (*argptr)
9057 argptr++; 9057 argptr++;
9058 } else if (cmdline && (c == '-')) { // long options 9058 } else if (cmdline && (c == 'l')) { /* -l or +l == --login */
9059 isloginsh = 1;
9060 /* bash does not accept +-login, we also won't */
9061 } else if (cmdline && val && (c == '-')) { /* long options */
9059 if (strcmp(p, "login") == 0) 9062 if (strcmp(p, "login") == 0)
9060 isloginsh = 1; 9063 isloginsh = 1;
9061 break; 9064 break;