[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH 4/5] ash: respect -p flag when command builtin is run with -v/-V
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2015-10-29 19:05:56
Message-ID: CAK1hOcNMgEJLkGGp0yVgDXs=h-L0Hadk--L=uE4T9oijop89nQ () mail ! gmail ! com
[Download RAW message or body]
Applied, thanks!
On Mon, Aug 3, 2015 at 2:47 PM, Ron Yorston <rmy@pobox.com> wrote:
> The command builtin should only check the default path, not $PATH,
> when the -p flag is used along with -v/-V.
>
> Based on commits 65ae84b (by Harald van Dijk) and 29ee27d (by Herbert
> Xu) from git://git.kernel.org/pub/scm/utils/dash/dash.git).
>
> function old new delta
> commandcmd 72 87 +15
> describe_command 437 450 +13
> typecmd 84 86 +2
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 3/0 up/down: 30/0) Total: 30 bytes
>
> Signed-off-by: Ron Yorston <rmy@pobox.com>
> ---
> shell/ash.c | 12 ++++++++----
> shell/ash_test/ash-misc/command.right | 1 +
> shell/ash_test/ash-misc/command.tests | 1 +
> 3 files changed, 10 insertions(+), 4 deletions(-)
> create mode 100644 shell/ash_test/ash-misc/command.right
> create mode 100755 shell/ash_test/ash-misc/command.tests
>
> diff --git a/shell/ash.c b/shell/ash.c
> index ddcd28b..7ba9a7f 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -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;
> diff --git a/shell/ash_test/ash-misc/command.right b/shell/ash_test/ash-misc/command.right
> new file mode 100644
> index 0000000..7f746d9
> --- /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 0000000..5d445af
> --- /dev/null
> +++ b/shell/ash_test/ash-misc/command.tests
> @@ -0,0 +1 @@
> +command -p -V recho
> --
> 2.4.3
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic