xargs: make -I imply -r
authorAaro Koskinen <aaro.koskinen@iki.fi>
Sat, 24 Oct 2015 20:01:29 +0000 (22:01 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 24 Oct 2015 20:01:29 +0000 (22:01 +0200)
Make -I imply -r (GNU findutils seems to do the same).

Fixes the following bug:

        $ echo -n | xargs -I% echo %
        Segmentation fault

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
findutils/xargs.c

index 5870b8a167631ca374c7d8adfa1f28c95e59c4ce..69f83b128969b1f5bbf9a207bccc327682d982ec 100644 (file)
@@ -577,6 +577,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
        {