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