hush: Fix assignments being misinterpreted as commands
If there were no variable substitutions in a command, then initial assignments would be misinterpreted as commands, instead of being skipped over. This is demonstrated by the following example: => foo=bar echo baz Unknown command 'foo=bar' - try 'help' Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
parent
c146de4872
commit
9539f71675
|
@ -1673,7 +1673,7 @@ static int run_pipe_real(struct pipe *pi)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Process the command */
|
/* Process the command */
|
||||||
return cmd_process(flag, child->argc, child->argv,
|
return cmd_process(flag, child->argc - i, child->argv + i,
|
||||||
&flag_repeat, NULL);
|
&flag_repeat, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ static struct test_data echo_data[] = {
|
||||||
*/
|
*/
|
||||||
{"setenv jQx X; echo \"a)\" ${jQx} 'b)' '${jQx}' c) ${jQx}; setenv jQx",
|
{"setenv jQx X; echo \"a)\" ${jQx} 'b)' '${jQx}' c) ${jQx}; setenv jQx",
|
||||||
"a) X b) ${jQx} c) X"},
|
"a) X b) ${jQx} c) X"},
|
||||||
|
/* Test shell variable assignments without substitutions */
|
||||||
|
{"foo=bar echo baz", "baz"},
|
||||||
/* Test handling of shell variables. */
|
/* Test handling of shell variables. */
|
||||||
{"setenv jQx; for jQx in 1 2 3; do echo -n \"${jQx}, \"; done; echo;",
|
{"setenv jQx; for jQx in 1 2 3; do echo -n \"${jQx}, \"; done; echo;",
|
||||||
"1, 2, 3, "},
|
"1, 2, 3, "},
|
||||||
|
|
Loading…
Reference in New Issue