hush: implement "command" builtin (no options are supported yet)
function old new delta pseudo_exec_argv 194 231 +37 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
1f1911239c
commit
3bb3e1d0a1
17
shell/hush.c
17
shell/hush.c
@ -58,6 +58,7 @@
|
||||
* (can use this to override standalone shell as well)
|
||||
* -p: use default $PATH
|
||||
* command BLTIN: disables special-ness (e.g. errors do not abort)
|
||||
* NB: so far, only naked "command CMD" is implemented.
|
||||
* fc -l[nr] [BEG] [END]: list range of commands in history
|
||||
* fc [-e EDITOR] [BEG] [END]: edit/rerun range of commands
|
||||
* fc -s [PAT=REP] [CMD]: rerun CMD, replacing PAT with REP
|
||||
@ -253,6 +254,11 @@
|
||||
//config: default y
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config:
|
||||
//config:config HUSH_COMMAND
|
||||
//config: bool "command builtin"
|
||||
//config: default y
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config:
|
||||
//config:config HUSH_TRAP
|
||||
//config: bool "trap builtin"
|
||||
//config: default y
|
||||
@ -7406,11 +7412,20 @@ static NOINLINE void pseudo_exec_argv(nommu_save_t *nommu_save,
|
||||
* if this is one of those cases.
|
||||
*/
|
||||
{
|
||||
const struct built_in_command *x;
|
||||
|
||||
#if ENABLE_HUSH_COMMAND
|
||||
/* This loop effectively makes "command BAR" run BAR without
|
||||
* looking it up among functions.
|
||||
*/
|
||||
while (strcmp(argv[0], "command") == 0 && argv[1])
|
||||
argv++;
|
||||
//TODO: implement -Vvp and "disable dying if BAR is a builtin" behavior
|
||||
#endif
|
||||
/* On NOMMU, it is more expensive to re-execute shell
|
||||
* just in order to run echo or test builtin.
|
||||
* It's better to skip it here and run corresponding
|
||||
* non-builtin later. */
|
||||
const struct built_in_command *x;
|
||||
x = BB_MMU ? find_builtin(argv[0]) : find_builtin1(argv[0]);
|
||||
if (x) {
|
||||
exec_builtin(&nommu_save->argv_from_re_execing, x, argv);
|
||||
|
Loading…
Reference in New Issue
Block a user