summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2019-11-24 19:55:47 +0100
committerBernhard Voelker <mail@bernhard-voelker.de>2019-11-25 22:39:33 +0100
commit6e55ad98b1d8c66b524fb415f08cd2a599c7e654 (patch)
tree8331e85a95b8417933642951cff1773586c960f7
parenta0169f9aac1fd65e835b9c0df4001a792716c589 (diff)
downloadfindutils-6e55ad98b.tar.gz
xargs: avoid trailing blank in -t,--verbose output
'xargs -t' had a trailing blank in the output, e.g.: $ echo a b | xargs -t 2>&1 | cat -e echo a b $ a b$ POSIX mandates that the constructed command line "shall be written to standard error, as it will be invoked", so avoid outputting the trailing blank. FWIW: This change still plays well with -p,--interactive, because POSIX says to just output "?..." as a prompt after the -t output. * xargs/xargs.c (print_args): Instead of outputting a blank after each cmd_argv[i], output a blank before each item unless for the first one. * tests/xargs/verbose-quote.sh: Remove trailing blanks from expected stderr. * xargs/testsuite/xargs.gnu/space-t-0.xe: Likewise. * xargs/testsuite/xargs.sysv/empty-t.xe: Likewise. * xargs/testsuite/xargs.sysv/empty_def-t.xe: Likewise. * xargs/testsuite/xargs.sysv/s25-t.xe: Likewise. * xargs/testsuite/xargs.sysv/space-t.xe: Likewise. * xargs/testsuite/xargs.sysv/trace.xe: Likewise. * NEWS: Mention the change. Reported by 積丹尼 Dan Jacobson <jidanni@jidanni.org> in: https://bugs.gnu.org/?57291
-rw-r--r--NEWS5
-rwxr-xr-xtests/xargs/verbose-quote.sh3
-rw-r--r--xargs/testsuite/xargs.gnu/space-t-0.xe2
-rw-r--r--xargs/testsuite/xargs.sysv/empty-t.xe2
-rw-r--r--xargs/testsuite/xargs.sysv/empty_def-t.xe2
-rw-r--r--xargs/testsuite/xargs.sysv/s25-t.xe12
-rw-r--r--xargs/testsuite/xargs.sysv/space-t.xe2
-rw-r--r--xargs/testsuite/xargs.sysv/trace.xe4
-rw-r--r--xargs/xargs.c3
9 files changed, 20 insertions, 15 deletions
diff --git a/NEWS b/NEWS
index cb84faf..66402a2 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release ?.?.?, YYYY-MM-DD
+** Changes in xargs
+
+'xargs -t' no longer outputs a trailing blank to stderr after the last argument
+of each constructed command line to be executed. [#57291]
+
** Bug Fixes
#54730: Add additional valuable example of find -quit
diff --git a/tests/xargs/verbose-quote.sh b/tests/xargs/verbose-quote.sh
index 2e8f3f3..61cbc66 100755
--- a/tests/xargs/verbose-quote.sh
+++ b/tests/xargs/verbose-quote.sh
@@ -38,8 +38,7 @@ printf '%s\0' \
|| fail=1
# Verify stderr.
-# Add trailing blank with sed to avoid FP from sc_trailing_blank.
-sed 's/world/& /' <<\EOF > experr || framework_failure_
+cat <<\EOF > experr || framework_failure_
'./my command' 'hel lo' 000 world
'./my command' 'hel lo' '10 0' world
'./my command' 'hel lo' '20"0' world
diff --git a/xargs/testsuite/xargs.gnu/space-t-0.xe b/xargs/testsuite/xargs.gnu/space-t-0.xe
index e10f822..555e43d 100644
--- a/xargs/testsuite/xargs.gnu/space-t-0.xe
+++ b/xargs/testsuite/xargs.gnu/space-t-0.xe
@@ -1 +1 @@
-echo this plus that ''$'\n'' '$'\f\r\t\v\n'
+echo this plus that ''$'\n'' '$'\f\r\t\v\n'
diff --git a/xargs/testsuite/xargs.sysv/empty-t.xe b/xargs/testsuite/xargs.sysv/empty-t.xe
index ec9c43d..19bef95 100644
--- a/xargs/testsuite/xargs.sysv/empty-t.xe
+++ b/xargs/testsuite/xargs.sysv/empty-t.xe
@@ -1 +1 @@
-echo this plus that
+echo this plus that
diff --git a/xargs/testsuite/xargs.sysv/empty_def-t.xe b/xargs/testsuite/xargs.sysv/empty_def-t.xe
index 1aa4903..fa11a6a 100644
--- a/xargs/testsuite/xargs.sysv/empty_def-t.xe
+++ b/xargs/testsuite/xargs.sysv/empty_def-t.xe
@@ -1 +1 @@
-echo
+echo
diff --git a/xargs/testsuite/xargs.sysv/s25-t.xe b/xargs/testsuite/xargs.sysv/s25-t.xe
index 5659900..a25e816 100644
--- a/xargs/testsuite/xargs.sysv/s25-t.xe
+++ b/xargs/testsuite/xargs.sysv/s25-t.xe
@@ -1,6 +1,6 @@
-echo 1 22 333 4444 55555
-echo 666666 7777777
-echo 88888888 999999999
-echo 1 22 333 4444 55555
-echo 666666 7777777
-echo 88888888 999999999
+echo 1 22 333 4444 55555
+echo 666666 7777777
+echo 88888888 999999999
+echo 1 22 333 4444 55555
+echo 666666 7777777
+echo 88888888 999999999
diff --git a/xargs/testsuite/xargs.sysv/space-t.xe b/xargs/testsuite/xargs.sysv/space-t.xe
index ec9c43d..19bef95 100644
--- a/xargs/testsuite/xargs.sysv/space-t.xe
+++ b/xargs/testsuite/xargs.sysv/space-t.xe
@@ -1 +1 @@
-echo this plus that
+echo this plus that
diff --git a/xargs/testsuite/xargs.sysv/trace.xe b/xargs/testsuite/xargs.sysv/trace.xe
index dfbe22e..4462d25 100644
--- a/xargs/testsuite/xargs.sysv/trace.xe
+++ b/xargs/testsuite/xargs.sysv/trace.xe
@@ -1,2 +1,2 @@
-echo foo bar
-echo baz ugh
+echo foo bar
+echo baz ugh
diff --git a/xargs/xargs.c b/xargs/xargs.c
index 824e9f0..56c872a 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -1093,7 +1093,8 @@ print_args (bool ask)
for (i = 0; i < bc_state.cmd_argc - 1; i++)
{
- if (fprintf (stderr, "%s ",
+ if (fprintf (stderr, "%s%s",
+ (i == 0 ? "" : " "),
quotearg_n_style (0, shell_escape_quoting_style,
bc_state.cmd_argv[i])) < 0)
die (EXIT_FAILURE, errno, _("Failed to write to stderr"));