aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-04-12 15:42:17 +0000
committerMatt Kraai <kraai@debian.org>2001-04-12 15:42:17 +0000
commitbe66ad3212ed728e0a5fa4b972a904a1aa0c9d51 (patch)
tree2c5ed4ba5f829d0e821e15ad871b871104544822
parent3e2ab88ee2e488df1b674655f0038729a635aa52 (diff)
downloadbusybox-be66ad3212ed728e0a5fa4b972a904a1aa0c9d51.tar.gz
Fix handling of '' and "".
-rw-r--r--lash.c10
-rw-r--r--sh.c10
-rw-r--r--shell/lash.c10
3 files changed, 18 insertions, 12 deletions
diff --git a/lash.c b/lash.c
index ee45b1a0d..69fcbe6be 100644
--- a/lash.c
+++ b/lash.c
@@ -1159,7 +1159,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
int argc_l = 0;
int done = 0;
int argv_alloced;
- int i;
+ int i, saw_quote = 0;
char quote = '\0';
int count;
struct child_prog *prog;
@@ -1221,7 +1221,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
*src == ']') *buf++ = '\\';
*buf++ = *src;
} else if (isspace(*src)) {
- if (*prog->argv[argc_l]) {
+ if (*prog->argv[argc_l] || saw_quote) {
buf++, argc_l++;
/* +1 here leaves room for the NULL which ends argv */
if ((argc_l + 1) == argv_alloced) {
@@ -1231,12 +1231,14 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
argv_alloced);
}
prog->argv[argc_l] = buf;
+ saw_quote = 0;
}
} else
switch (*src) {
case '"':
case '\'':
quote = *src;
+ saw_quote = 1;
break;
case '#': /* comment */
@@ -1305,7 +1307,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
case '|': /* pipe */
/* finish this command */
- if (*prog->argv[argc_l])
+ if (*prog->argv[argc_l] || saw_quote)
argc_l++;
if (!argc_l) {
error_msg("empty command in pipe");
@@ -1474,7 +1476,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
src++;
}
- if (*prog->argv[argc_l]) {
+ if (*prog->argv[argc_l] || saw_quote) {
argc_l++;
}
if (!argc_l) {
diff --git a/sh.c b/sh.c
index ee45b1a0d..69fcbe6be 100644
--- a/sh.c
+++ b/sh.c
@@ -1159,7 +1159,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
int argc_l = 0;
int done = 0;
int argv_alloced;
- int i;
+ int i, saw_quote = 0;
char quote = '\0';
int count;
struct child_prog *prog;
@@ -1221,7 +1221,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
*src == ']') *buf++ = '\\';
*buf++ = *src;
} else if (isspace(*src)) {
- if (*prog->argv[argc_l]) {
+ if (*prog->argv[argc_l] || saw_quote) {
buf++, argc_l++;
/* +1 here leaves room for the NULL which ends argv */
if ((argc_l + 1) == argv_alloced) {
@@ -1231,12 +1231,14 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
argv_alloced);
}
prog->argv[argc_l] = buf;
+ saw_quote = 0;
}
} else
switch (*src) {
case '"':
case '\'':
quote = *src;
+ saw_quote = 1;
break;
case '#': /* comment */
@@ -1305,7 +1307,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
case '|': /* pipe */
/* finish this command */
- if (*prog->argv[argc_l])
+ if (*prog->argv[argc_l] || saw_quote)
argc_l++;
if (!argc_l) {
error_msg("empty command in pipe");
@@ -1474,7 +1476,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
src++;
}
- if (*prog->argv[argc_l]) {
+ if (*prog->argv[argc_l] || saw_quote) {
argc_l++;
}
if (!argc_l) {
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)
int argc_l = 0;
int done = 0;
int argv_alloced;
- int i;
+ int i, saw_quote = 0;
char quote = '\0';
int count;
struct child_prog *prog;
@@ -1221,7 +1221,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
*src == ']') *buf++ = '\\';
*buf++ = *src;
} else if (isspace(*src)) {
- if (*prog->argv[argc_l]) {
+ if (*prog->argv[argc_l] || saw_quote) {
buf++, argc_l++;
/* +1 here leaves room for the NULL which ends argv */
if ((argc_l + 1) == argv_alloced) {
@@ -1231,12 +1231,14 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
argv_alloced);
}
prog->argv[argc_l] = buf;
+ saw_quote = 0;
}
} else
switch (*src) {
case '"':
case '\'':
quote = *src;
+ saw_quote = 1;
break;
case '#': /* comment */
@@ -1305,7 +1307,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
case '|': /* pipe */
/* finish this command */
- if (*prog->argv[argc_l])
+ if (*prog->argv[argc_l] || saw_quote)
argc_l++;
if (!argc_l) {
error_msg("empty command in pipe");
@@ -1474,7 +1476,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
src++;
}
- if (*prog->argv[argc_l]) {
+ if (*prog->argv[argc_l] || saw_quote) {
argc_l++;
}
if (!argc_l) {