diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-14 11:33:10 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-14 11:33:10 +0000 |
commit | 8fdc4b7b06ada63a2572f8aff92e8810e52ae841 (patch) | |
tree | 5e4c13a621c5e7bde70e8cc37d3e7f2fed9cd33c | |
parent | 40ba9984fd363cfceb2f7f10a882ade282a195aa (diff) | |
download | busybox-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.c | 21 |
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 | ||
135 | static char *minusc; /* argument to -c option */ | 135 | static char *minusc; /* argument to -c option */ |
136 | 136 | ||
137 | static int isloginsh; | ||
138 | /* pid of main shell */ | 137 | /* pid of main shell */ |
139 | static int rootpid; | 138 | static 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 */ |
144 | static char *trap[NSIG]; | 143 | static char *trap[NSIG]; |
144 | static smallint isloginsh; | ||
145 | /* current value of signal */ | 145 | /* current value of signal */ |
146 | static char sigmode[NSIG - 1]; | 146 | static 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; |