hush: document better where bad redirect syntax is detected
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4ff86df861
commit
d6a37d86ba
23
shell/hush.c
23
shell/hush.c
@ -3054,6 +3054,14 @@ static int done_command(struct parse_context *ctx)
|
|||||||
struct pipe *pi = ctx->pipe;
|
struct pipe *pi = ctx->pipe;
|
||||||
struct command *command = ctx->command;
|
struct command *command = ctx->command;
|
||||||
|
|
||||||
|
#if 0 /* Instead we emit error message at run time */
|
||||||
|
if (ctx->pending_redirect) {
|
||||||
|
/* For example, "cmd >" (no filename to redirect to) */
|
||||||
|
die_if_script("syntax error: %s", "invalid redirect");
|
||||||
|
ctx->pending_redirect = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
if (IS_NULL_CMD(command)) {
|
if (IS_NULL_CMD(command)) {
|
||||||
debug_printf_parse("done_command: skipping null cmd, num_cmds=%d\n", pi->num_cmds);
|
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,
|
|||||||
debug_printf_parse("duplicating redirect '%d>&%d'\n",
|
debug_printf_parse("duplicating redirect '%d>&%d'\n",
|
||||||
redir->rd_fd, redir->rd_dup);
|
redir->rd_fd, redir->rd_dup);
|
||||||
} else {
|
} else {
|
||||||
|
#if 0 /* Instead we emit error message at run time */
|
||||||
|
if (ctx->pending_redirect) {
|
||||||
|
/* For example, "cmd > <file" */
|
||||||
|
die_if_script("syntax error: %s", "invalid redirect");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* Set ctx->pending_redirect, so we know what to do at the
|
/* Set ctx->pending_redirect, so we know what to do at the
|
||||||
* end of the next parsed word. */
|
* end of the next parsed word. */
|
||||||
ctx->pending_redirect = redir;
|
ctx->pending_redirect = redir;
|
||||||
@ -6276,9 +6290,12 @@ static int setup_redirects(struct command *prog, int squirrel[])
|
|||||||
/* "rd_fd<*>file" case (<*> is <,>,>>,<>) */
|
/* "rd_fd<*>file" case (<*> is <,>,>>,<>) */
|
||||||
char *p;
|
char *p;
|
||||||
if (redir->rd_filename == NULL) {
|
if (redir->rd_filename == NULL) {
|
||||||
/* Something went wrong in the parse.
|
/*
|
||||||
* Pretend it didn't happen */
|
* Examples:
|
||||||
bb_error_msg("bug in redirect parse");
|
* "cmd >" (no filename)
|
||||||
|
* "cmd > <file" (2nd redirect starts too early)
|
||||||
|
*/
|
||||||
|
die_if_script("syntax error: %s", "invalid redirect");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mode = redir_table[redir->rd_type].mode;
|
mode = redir_table[redir->rd_type].mode;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user