*: add most of the required setup_common_bufsiz() calls
[oweals/busybox.git] / findutils / xargs.c
index 76c4747fe590f9f31011e9d6a51441b0d69cda1d..ae01a49beaf8cb151ddece900e50df613d22bb84 100644 (file)
@@ -66,6 +66,7 @@
 //kbuild:lib-$(CONFIG_XARGS) += xargs.o
 
 #include "libbb.h"
+#include "common_bufsiz.h"
 
 /* This is a NOEXEC applet. Be very careful! */
 
@@ -100,8 +101,9 @@ struct globals {
        const char *eof_str;
        int idx;
 } FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
 #define INIT_G() do { \
+       setup_common_bufsiz(); \
        G.eof_str = NULL; /* need to clear by hand because we are NOEXEC applet */ \
        IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.repl_str = "{}";) \
        IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.eol_ch = '\n';) \
@@ -122,7 +124,7 @@ static int xargs_exec(void)
                return 124;
        }
        if (status >= 0x180) {
-               bb_error_msg("%s: terminated by signal %d",
+               bb_error_msg("'%s' terminated by signal %d",
                        G.args[0], status - 0x180);
                return 125;
        }
@@ -151,7 +153,7 @@ static void store_param(char *s)
  * is seen, store the address of a new parameter to args[].
  * If reading discovers that last chars do not form the complete
  * parameter, the pointer to the first such "tail character" is returned.
- * (buf has extra byte at the end to accomodate terminating NUL
+ * (buf has extra byte at the end to accommodate terminating NUL
  * of "tail characters" string).
  * Otherwise, the returned pointer points to NUL byte.
  * On entry, buf[] may contain some "seed chars" which are to become
@@ -577,6 +579,9 @@ int xargs_main(int argc, char **argv)
                G.argv = argv;
                argc = 0;
                read_args = process_stdin_with_replace;
+               /* Make -I imply -r. GNU findutils seems to do the same: */
+               /* (otherwise "echo -n | xargs -I% echo %" would SEGV) */
+               opt |= OPT_NO_EMPTY;
        } else
 #endif
        {