diff options
-rw-r--r-- | shell/ash.c | 12 | ||||
-rw-r--r-- | shell/ash_test/ash-misc/command.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-misc/command.tests | 1 |
3 files changed, 10 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c index 8f0a5e0be..a2e06184b 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -7812,14 +7812,15 @@ findkwd(const char *s) | |||
7812 | * Locate and print what a word is... | 7812 | * Locate and print what a word is... |
7813 | */ | 7813 | */ |
7814 | static int | 7814 | static int |
7815 | describe_command(char *command, int describe_command_verbose) | 7815 | describe_command(char *command, const char *path, int describe_command_verbose) |
7816 | { | 7816 | { |
7817 | struct cmdentry entry; | 7817 | struct cmdentry entry; |
7818 | struct tblentry *cmdp; | 7818 | struct tblentry *cmdp; |
7819 | #if ENABLE_ASH_ALIAS | 7819 | #if ENABLE_ASH_ALIAS |
7820 | const struct alias *ap; | 7820 | const struct alias *ap; |
7821 | #endif | 7821 | #endif |
7822 | const char *path = pathval(); | 7822 | |
7823 | path = path ? path : pathval(); | ||
7823 | 7824 | ||
7824 | if (describe_command_verbose) { | 7825 | if (describe_command_verbose) { |
7825 | out1str(command); | 7826 | out1str(command); |
@@ -7919,7 +7920,7 @@ typecmd(int argc UNUSED_PARAM, char **argv) | |||
7919 | verbose = 0; | 7920 | verbose = 0; |
7920 | } | 7921 | } |
7921 | while (argv[i]) { | 7922 | while (argv[i]) { |
7922 | err |= describe_command(argv[i++], verbose); | 7923 | err |= describe_command(argv[i++], NULL, verbose); |
7923 | } | 7924 | } |
7924 | return err; | 7925 | return err; |
7925 | } | 7926 | } |
@@ -7933,6 +7934,7 @@ commandcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
7933 | VERIFY_BRIEF = 1, | 7934 | VERIFY_BRIEF = 1, |
7934 | VERIFY_VERBOSE = 2, | 7935 | VERIFY_VERBOSE = 2, |
7935 | } verify = 0; | 7936 | } verify = 0; |
7937 | const char *path = NULL; | ||
7936 | 7938 | ||
7937 | while ((c = nextopt("pvV")) != '\0') | 7939 | while ((c = nextopt("pvV")) != '\0') |
7938 | if (c == 'V') | 7940 | if (c == 'V') |
@@ -7943,9 +7945,11 @@ commandcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
7943 | else if (c != 'p') | 7945 | else if (c != 'p') |
7944 | abort(); | 7946 | abort(); |
7945 | #endif | 7947 | #endif |
7948 | else | ||
7949 | path = bb_default_path; | ||
7946 | /* Mimic bash: just "command -v" doesn't complain, it's a nop */ | 7950 | /* Mimic bash: just "command -v" doesn't complain, it's a nop */ |
7947 | if (verify && (*argptr != NULL)) { | 7951 | if (verify && (*argptr != NULL)) { |
7948 | return describe_command(*argptr, verify - VERIFY_BRIEF); | 7952 | return describe_command(*argptr, path, verify - VERIFY_BRIEF); |
7949 | } | 7953 | } |
7950 | 7954 | ||
7951 | return 0; | 7955 | return 0; |
diff --git a/shell/ash_test/ash-misc/command.right b/shell/ash_test/ash-misc/command.right new file mode 100644 index 000000000..7f746d9c4 --- /dev/null +++ b/shell/ash_test/ash-misc/command.right | |||
@@ -0,0 +1 @@ | |||
recho: not found | |||
diff --git a/shell/ash_test/ash-misc/command.tests b/shell/ash_test/ash-misc/command.tests new file mode 100755 index 000000000..5d445af51 --- /dev/null +++ b/shell/ash_test/ash-misc/command.tests | |||
@@ -0,0 +1 @@ | |||
command -p -V recho | |||