diff options
author | Matt Kraai <kraai@debian.org> | 2001-04-12 15:42:17 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2001-04-12 15:42:17 +0000 |
commit | be66ad3212ed728e0a5fa4b972a904a1aa0c9d51 (patch) | |
tree | 2c5ed4ba5f829d0e821e15ad871b871104544822 /shell/lash.c | |
parent | 3e2ab88ee2e488df1b674655f0038729a635aa52 (diff) | |
download | busybox-w32-be66ad3212ed728e0a5fa4b972a904a1aa0c9d51.tar.gz busybox-w32-be66ad3212ed728e0a5fa4b972a904a1aa0c9d51.tar.bz2 busybox-w32-be66ad3212ed728e0a5fa4b972a904a1aa0c9d51.zip |
Fix handling of '' and "".
Diffstat (limited to 'shell/lash.c')
-rw-r--r-- | shell/lash.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/shell/lash.c b/shell/lash.c index ee45b1a0d..69fcbe6be 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -1159,7 +1159,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1159 | int argc_l = 0; | 1159 | int argc_l = 0; |
1160 | int done = 0; | 1160 | int done = 0; |
1161 | int argv_alloced; | 1161 | int argv_alloced; |
1162 | int i; | 1162 | int i, saw_quote = 0; |
1163 | char quote = '\0'; | 1163 | char quote = '\0'; |
1164 | int count; | 1164 | int count; |
1165 | struct child_prog *prog; | 1165 | struct child_prog *prog; |
@@ -1221,7 +1221,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1221 | *src == ']') *buf++ = '\\'; | 1221 | *src == ']') *buf++ = '\\'; |
1222 | *buf++ = *src; | 1222 | *buf++ = *src; |
1223 | } else if (isspace(*src)) { | 1223 | } else if (isspace(*src)) { |
1224 | if (*prog->argv[argc_l]) { | 1224 | if (*prog->argv[argc_l] || saw_quote) { |
1225 | buf++, argc_l++; | 1225 | buf++, argc_l++; |
1226 | /* +1 here leaves room for the NULL which ends argv */ | 1226 | /* +1 here leaves room for the NULL which ends argv */ |
1227 | if ((argc_l + 1) == argv_alloced) { | 1227 | if ((argc_l + 1) == argv_alloced) { |
@@ -1231,12 +1231,14 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1231 | argv_alloced); | 1231 | argv_alloced); |
1232 | } | 1232 | } |
1233 | prog->argv[argc_l] = buf; | 1233 | prog->argv[argc_l] = buf; |
1234 | saw_quote = 0; | ||
1234 | } | 1235 | } |
1235 | } else | 1236 | } else |
1236 | switch (*src) { | 1237 | switch (*src) { |
1237 | case '"': | 1238 | case '"': |
1238 | case '\'': | 1239 | case '\'': |
1239 | quote = *src; | 1240 | quote = *src; |
1241 | saw_quote = 1; | ||
1240 | break; | 1242 | break; |
1241 | 1243 | ||
1242 | case '#': /* comment */ | 1244 | case '#': /* comment */ |
@@ -1305,7 +1307,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1305 | 1307 | ||
1306 | case '|': /* pipe */ | 1308 | case '|': /* pipe */ |
1307 | /* finish this command */ | 1309 | /* finish this command */ |
1308 | if (*prog->argv[argc_l]) | 1310 | if (*prog->argv[argc_l] || saw_quote) |
1309 | argc_l++; | 1311 | argc_l++; |
1310 | if (!argc_l) { | 1312 | if (!argc_l) { |
1311 | error_msg("empty command in pipe"); | 1313 | error_msg("empty command in pipe"); |
@@ -1474,7 +1476,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1474 | src++; | 1476 | src++; |
1475 | } | 1477 | } |
1476 | 1478 | ||
1477 | if (*prog->argv[argc_l]) { | 1479 | if (*prog->argv[argc_l] || saw_quote) { |
1478 | argc_l++; | 1480 | argc_l++; |
1479 | } | 1481 | } |
1480 | if (!argc_l) { | 1482 | if (!argc_l) { |