summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2018-01-11 18:05:05 +0100
committerDenys Vlasenko2018-01-11 18:05:05 +0100
commit3bb3e1d0a1eed01306e22e59db8de6c2d945165a (patch)
treef2df470ae2de4417fad4c2f75f33bc544e92a454
parent1f1911239c0874d49a31d0ef2e618d0a1086a8df (diff)
downloadbusybox-3bb3e1d0a1eed01306e22e59db8de6c2d945165a.zip
busybox-3bb3e1d0a1eed01306e22e59db8de6c2d945165a.tar.gz
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>
-rw-r--r--shell/hush.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index c2b987f..93779ba 100644
--- a/shell/hush.c
+++ b/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);