diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-09-20 16:22:24 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-09-20 16:22:24 +0200 |
commit | d6a37d86ba65ce3d43600bfc52f7ba56de68942d (patch) | |
tree | 3ba60c14be6100c5b3309d012ae633fd5907b7c7 | |
parent | 4ff86df861069e51ee796bac4e8ead942f8985f5 (diff) | |
download | busybox-w32-d6a37d86ba65ce3d43600bfc52f7ba56de68942d.tar.gz busybox-w32-d6a37d86ba65ce3d43600bfc52f7ba56de68942d.tar.bz2 busybox-w32-d6a37d86ba65ce3d43600bfc52f7ba56de68942d.zip |
hush: document better where bad redirect syntax is detected
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c index a8ec54ec0..e2b0a15b8 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -3054,6 +3054,14 @@ static int done_command(struct parse_context *ctx) | |||
3054 | struct pipe *pi = ctx->pipe; | 3054 | struct pipe *pi = ctx->pipe; |
3055 | struct command *command = ctx->command; | 3055 | struct command *command = ctx->command; |
3056 | 3056 | ||
3057 | #if 0 /* Instead we emit error message at run time */ | ||
3058 | if (ctx->pending_redirect) { | ||
3059 | /* For example, "cmd >" (no filename to redirect to) */ | ||
3060 | die_if_script("syntax error: %s", "invalid redirect"); | ||
3061 | ctx->pending_redirect = NULL; | ||
3062 | } | ||
3063 | #endif | ||
3064 | |||
3057 | if (command) { | 3065 | if (command) { |
3058 | if (IS_NULL_CMD(command)) { | 3066 | if (IS_NULL_CMD(command)) { |
3059 | debug_printf_parse("done_command: skipping null cmd, num_cmds=%d\n", pi->num_cmds); | 3067 | debug_printf_parse("done_command: skipping null cmd, num_cmds=%d\n", pi->num_cmds); |
@@ -3576,6 +3584,12 @@ static int parse_redirect(struct parse_context *ctx, | |||
3576 | debug_printf_parse("duplicating redirect '%d>&%d'\n", | 3584 | debug_printf_parse("duplicating redirect '%d>&%d'\n", |
3577 | redir->rd_fd, redir->rd_dup); | 3585 | redir->rd_fd, redir->rd_dup); |
3578 | } else { | 3586 | } else { |
3587 | #if 0 /* Instead we emit error message at run time */ | ||
3588 | if (ctx->pending_redirect) { | ||
3589 | /* For example, "cmd > <file" */ | ||
3590 | die_if_script("syntax error: %s", "invalid redirect"); | ||
3591 | } | ||
3592 | #endif | ||
3579 | /* Set ctx->pending_redirect, so we know what to do at the | 3593 | /* Set ctx->pending_redirect, so we know what to do at the |
3580 | * end of the next parsed word. */ | 3594 | * end of the next parsed word. */ |
3581 | ctx->pending_redirect = redir; | 3595 | ctx->pending_redirect = redir; |
@@ -6276,9 +6290,12 @@ static int setup_redirects(struct command *prog, int squirrel[]) | |||
6276 | /* "rd_fd<*>file" case (<*> is <,>,>>,<>) */ | 6290 | /* "rd_fd<*>file" case (<*> is <,>,>>,<>) */ |
6277 | char *p; | 6291 | char *p; |
6278 | if (redir->rd_filename == NULL) { | 6292 | if (redir->rd_filename == NULL) { |
6279 | /* Something went wrong in the parse. | 6293 | /* |
6280 | * Pretend it didn't happen */ | 6294 | * Examples: |
6281 | bb_error_msg("bug in redirect parse"); | 6295 | * "cmd >" (no filename) |
6296 | * "cmd > <file" (2nd redirect starts too early) | ||
6297 | */ | ||
6298 | die_if_script("syntax error: %s", "invalid redirect"); | ||
6282 | continue; | 6299 | continue; |
6283 | } | 6300 | } |
6284 | mode = redir_table[redir->rd_type].mode; | 6301 | mode = redir_table[redir->rd_type].mode; |