[bug #64816] support ls' --quoting-style= option

Christoph Anton Mitterer <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
Follow-up Comment #1, bug #64816 (project findutils):

Maybe it would also make sense to add the same functionality to xargs.

The idea is, that (POSIX compatible) shells don't work very well with NULL
delimited output.

If some program produces such, it's output could be piped into xargs -0 ...
and if that would now have an output mode that produces a string that is
re-usable in the shell, one could rather easily get e.g. strings with trailing
newlines into shell variables.

Something like:
eval "set -- $(  printf 'a\n\0b\nc\0d\n\n' | xargs -0 --
--quoting-style=shell-escape )"

where the printf simulates an arbitrary program that outputs byte strings
NULL-delimited, which are then read by xargs and printed again but escaped for
the shell to be re-used as input (without any command substitutions, etc.
happening)... and in this example, set as the new positional parameters, which
might be quite handy for e.g. shell functions.


[ Also notice, that this is not easily doable with shell command substitution
( $(... ) ) as that drops trailing newlines.
And yes I know, there are hacks around that (using sentinel values) but making
the truly portable is something between tricky/fragile to not possible. ]


Just an idea though.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64816>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.