← Commit list

3f221113a

Ron Yorston
Ron Yorston
2015-10-29
SUCCESS Duration: 244s

Subject

ash: respect -p flag when command builtin is run with -v/-V

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+8 -4
@@ -7812,14 +7812,15 @@ findkwd(const char *s)
* Locate and print what a word is...
*/
static int
-describe_command(char *command, int describe_command_verbose)
+describe_command(char *command, const char *path, int describe_command_verbose)
{
struct cmdentry entry;
struct tblentry *cmdp;
#if ENABLE_ASH_ALIAS
const struct alias *ap;
#endif
- const char *path = pathval();
+
+ path = path ? path : pathval();
if (describe_command_verbose) {
out1str(command);
@@ -7919,7 +7920,7 @@ typecmd(int argc UNUSED_PARAM, char **argv)
verbose = 0;
}
while (argv[i]) {
- err |= describe_command(argv[i++], verbose);
+ err |= describe_command(argv[i++], NULL, verbose);
}
return err;
}
@@ -7933,6 +7934,7 @@ commandcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
VERIFY_BRIEF = 1,
VERIFY_VERBOSE = 2,
} verify = 0;
+ const char *path = NULL;
while ((c = nextopt("pvV")) != '\0')
if (c == 'V')
@@ -7943,9 +7945,11 @@ commandcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
else if (c != 'p')
abort();
#endif
+ else
+ path = bb_default_path;
/* Mimic bash: just "command -v" doesn't complain, it's a nop */
if (verify && (*argptr != NULL)) {
- return describe_command(*argptr, verify - VERIFY_BRIEF);
+ return describe_command(*argptr, path, verify - VERIFY_BRIEF);
}
return 0;
shell/ash_test/ash-misc/command.right+1 -0
@@ -0,0 +1 @@
+recho: not found
shell/ash_test/ash-misc/command.tests+1 -0
@@ -0,0 +1 @@
+command -p -V recho