[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xargs prompts with the same string, but executes differently
From: |
Eric Blake |
Subject: |
Re: xargs prompts with the same string, but executes differently |
Date: |
Wed, 24 Jul 2019 16:28:29 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 7/24/19 4:20 PM, Bernhard Voelker wrote:
> I agree that another new option is way too much. That question to the user
> is meant for interactive use only anyway, so what about simply:
>
> diff --git a/xargs/xargs.c b/xargs/xargs.c
> index 913328b8..85084123 100644
> --- a/xargs/xargs.c
> +++ b/xargs/xargs.c
> @@ -1093,7 +1093,7 @@ print_args (bool ask)
>
> for (i = 0; i < bc_state.cmd_argc - 1; i++)
> {
> - if (fprintf (stderr, "%s ", bc_state.cmd_argv[i]) < 0)
> + if (fprintf (stderr, "%s ", quotearg_n_style (0,
> shell_escape_quoting_style, bc_state.cmd_argv[i])) < 0)
> die (EXIT_FAILURE, errno, _("Failed to write to stderr"));
Looks reasonable to me (other than line wrapping).
> }
>
> Example:
>
> $ printf '%s\0' 000 '0 0' '0"0' "0'0" \
> | xargs/xargs -0p '-I{}' echo hello '{}' world
> echo hello 000 world ?...y
> hello 000 world
> echo hello '0 0' world ?...y
> hello 0 0 world
> echo hello '0"0' world ?...y
> hello 0"0 world
> echo hello "0'0" world ?...y
> hello 0'0 world
>
> Well, this also changes plain -t output (i.e., without -p), but it's not
> that bad actually: it doesn't seem to be specified anywhere how -t output
> should look like. Just in case, we could still guard quotearg_n_style
> by "if (ask)".
POSIX merely says that -p implies -t, so I argue that consistency
between the two is better than only doing it for -p. I also agree that
POSIX doesn't seem to have any hard rules about what the format should
be, so doing the quoting unconditionally looks compliant.
>
> Do you see any drawback / corner case?
Not so far.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- xargs prompts with the same string, but executes differently, 積丹尼 Dan Jacobson, 2019/07/23
- Re: xargs prompts with the same string, but executes differently, Assaf Gordon, 2019/07/23
- Re: xargs prompts with the same string, but executes differently, Eric Blake, 2019/07/23
- Re: xargs prompts with the same string, but executes differently, 積丹尼 Dan Jacobson, 2019/07/23
- Re: xargs prompts with the same string, but executes differently, James Youngman, 2019/07/24
- Re: xargs prompts with the same string, but executes differently, Eric Blake, 2019/07/24
- Re: xargs prompts with the same string, but executes differently, Bernhard Voelker, 2019/07/24
- Re: xargs prompts with the same string, but executes differently,
Eric Blake <=
- Re: xargs prompts with the same string, but executes differently, 積丹尼 Dan Jacobson, 2019/07/25
- Re: xargs prompts with the same string, but executes differently, James Youngman, 2019/07/25
- Re: xargs prompts with the same string, but executes differently, 積丹尼 Dan Jacobson, 2019/07/25
- Re: xargs prompts with the same string, but executes differently, Bernhard Voelker, 2019/07/29
- Re: xargs prompts with the same string, but executes differently, 積丹尼 Dan Jacobson, 2019/07/29
- Re: xargs prompts with the same string, but executes differently, 積丹尼 Dan Jacobson, 2019/07/29
- Re: xargs prompts with the same string, but executes differently, Eric Blake, 2019/07/29
- Re: xargs prompts with the same string, but executes differently, 積丹尼 Dan Jacobson, 2019/07/29
- Re: xargs prompts with the same string, but executes differently, Bernhard Voelker, 2019/07/29
- Re: xargs prompts with the same string, but executes differently, Bernhard Voelker, 2019/07/31