aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--findutils/xargs.c8
-rwxr-xr-xtestsuite/xargs.tests19
2 files changed, 26 insertions, 1 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 8f0a3d4ad..92d01f7b6 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -376,6 +376,8 @@ enum {
376int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 376int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
377int xargs_main(int argc, char **argv) 377int xargs_main(int argc, char **argv)
378{ 378{
379 static const char const_eof_str[] ALIGN1 = "_";
380
379 char **args; 381 char **args;
380 int i, n; 382 int i, n;
381 xlist_t *list = NULL; 383 xlist_t *list = NULL;
@@ -385,7 +387,7 @@ int xargs_main(int argc, char **argv)
385 int n_max_arg; 387 int n_max_arg;
386 size_t n_chars = 0; 388 size_t n_chars = 0;
387 long orig_arg_max; 389 long orig_arg_max;
388 const char *eof_str = "_"; 390 const char *eof_str = const_eof_str;
389 unsigned opt; 391 unsigned opt;
390 size_t n_max_chars; 392 size_t n_max_chars;
391#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 393#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
@@ -396,6 +398,10 @@ int xargs_main(int argc, char **argv)
396 398
397 opt = getopt32(argv, OPTION_STR, &max_args, &max_chars, &eof_str); 399 opt = getopt32(argv, OPTION_STR, &max_args, &max_chars, &eof_str);
398 400
401 /* -e without optional param? */
402 if ((opt & OPT_EOF_STRING) && eof_str == const_eof_str)
403 eof_str = NULL;
404
399 if (opt & OPT_ZEROTERM) 405 if (opt & OPT_ZEROTERM)
400 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args = process0_stdin); 406 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args = process0_stdin);
401 407
diff --git a/testsuite/xargs.tests b/testsuite/xargs.tests
new file mode 100755
index 000000000..e041d592e
--- /dev/null
+++ b/testsuite/xargs.tests
@@ -0,0 +1,19 @@
1#!/bin/sh
2# Copyright 2008 by Denys Vlasenko
3# Licensed under GPL v2, see file LICENSE for details.
4
5. testing.sh
6
7# testing "test name" "command" "expected result" "file input" "stdin"
8
9testing "xargs stops on underscore" \
10 "xargs" \
11 "a\n" \
12 "" "a\n_\nb\n"
13
14testing "xargs -e without param" \
15 "xargs -e" \
16 "a _ b\n" \
17 "" "a\n_\nb\n"
18
19exit $FAILCOUNT