mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Tweak and regress-test 'command -x' (re: 66e1d446
)
Turns out the assumption I was operating on, that Linux and macOS align arguments on 32 or 64 bit boundaries, is incorrect -- they just need some extra bytes per argument. So we can use a bit more of the arguments buffer on these systems than I thought. src/cmd/ksh93/features/externs: - Change the feature test to simply detect the # of extra bytes per argument needed. On *BSD and commercial Unices, ARG_EXTRA_BYTES shows as zero; on Linux and macOS (64-bit), this yields 8. On Linux (32-bit), this yields 4. src/cmd/ksh93/sh/path.c: path_xargs(): - Do not try to calculate alignment, just add ARG_EXTRA_BYTES to each argument. - Also add this when substracting the length of environment variables and leading and trailing static command arguments. src/cmd/ksh93/tests/path.sh: - Test command -v/-V with -x. - Add a robust regression test for command -x. src/cmd/ksh93/data/builtins.c, src/cmd/ksh93/sh.1: - Tweak docs. Glob patterns also expand to multiple words.
This commit is contained in:
parent
f37098f177
commit
6a0e9a1a75
6 changed files with 103 additions and 44 deletions
|
@ -5847,16 +5847,16 @@ The
|
|||
option runs
|
||||
.I name\^
|
||||
as an external command, bypassing built-ins.
|
||||
If the arguments contain a word that expands to multiple arguments, such as
|
||||
\f3"$@"\fP or \f3"${array[@]}"\fP, then the
|
||||
If the arguments contain at least one word that expands to multiple arguments,
|
||||
such as \f3"$@"\fP or \f3*.txt\fP, then the
|
||||
.B \-x
|
||||
option also allows executing external commands with argument lists that are
|
||||
longer than the operating system allows. This functionality is similar to
|
||||
.BR xargs (1)
|
||||
but is easier to use. The shell does this by invoking the external command
|
||||
multiple times if needed, dividing the expanded argument list over the
|
||||
invocations. Any arguments that come before the first \f3"$@"\fP or similar
|
||||
expansion, as well as any that follow the last \f3"$@"\fP or similar, are
|
||||
invocations. Any arguments that come before the first word that expands to
|
||||
multiple arguments, as well as any that follow the last such word, are
|
||||
considered static arguments and are repeated for each invocation. This allows
|
||||
each invocation to use the same command options, as well as the same trailing
|
||||
destination arguments for commands like
|
||||
|
@ -5869,8 +5869,8 @@ exits with the status of the invocation that had the highest exit status.
|
|||
(Note that
|
||||
.B "command \-x"
|
||||
may still fail with an "argument list too long" error if a single argument
|
||||
exceeds the maximum length of the argument list, or if no \f3"$@"\fP or
|
||||
similar expansion was used.)
|
||||
exceeds the maximum length of the argument list, or if a long arguments
|
||||
list contains no word that expands to multiple arguments.)
|
||||
.TP
|
||||
\(dd \f3compound\fP \f2vname\fP\*(OK\f3=\fP\f2value\^\fP\*(CK .\|.\|.
|
||||
Causes each
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue