bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Christoph Anton Mitterer
Subject: [bug #64816] support ls' --quoting-style= option
Date: Thu, 26 Oct 2023 05:52:08 -0400 (EDT)

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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]