Liste des Groupes | Revenir à cu shell |
Helmut Waitzmann wrote:I'm glad to read that. I didn't know either.
>If ‘p_sort’ is designed to output the sorted file names separated by an ASCII NUL character rather than a newline then, using the GNU version of ‘xargs’, one can feed that output into ‘xargs’: >>
>
{
p_sort P*.HTM 3<&- |
xargs --null --no-run-if-empty -- sh -c \
'exec 0<&3 3<&- "$@"' sh \
viewer
} 3<&0
NUL as a record separator is also supported by several other versions of xargs, and it is in the recently released POSIX.1-2024 standard. >
In all of those it is specified with -0, so using -0 is more portable than the GNU-specific --null. >Yes, of course: If ‘-0’ is in the POSIX standard, it is preferable over ‘--null’.
POSIX.1-2024 also has -r although I think that's not as widely supported in current xargs implementations as -0. It should become better supported over time, though, so again I would suggest using -r rather than --no-run-if-empty for better future portability. >I didn't know, that ‘-0’ as well as ‘-r’ are more widely available (with the same semantics) than just in the GNU version. To minimize the risk of having a ‘xargs’ version, which by accident uses the options ‘-0’ or ‘-r’ with different semantics than GNU ‘xargs’ does, I preferred the long options (in particular ‘--no-run-if-empty’) over the short.
Les messages affichés proviennent d'usenet.