[BusyBox 0004414]: xargs in version 1.11.1 has incorrect default for -e option

bugs at busybox.net bugs at busybox.net
Sun Aug 3 19:10:47 UTC 2008


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=4414 
====================================================================== 
Reported By:                Araneidae
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   4414
Category:                   Other
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             08-01-2008 00:06 PDT
Last Modified:              08-03-2008 12:10 PDT
====================================================================== 
Summary:                    xargs in version 1.11.1 has incorrect default for -e
option
Description: 
The (undocumented) -e option for xargs, used to define an argument to be
treated as end of input (sets eof_str), has two problems.

1. The default value is "_".  This means that by default an argument of _
will be treated as end of input.  This is not a nice surprise!

2. The argument is current marked as taking an option value -- which means
that I can't specify an empty string to be end of input, which would
actually be useful.

The patch I attach below fixes both these issues, but does have the
disadvantage of introducing an incompatible change in behaviour.  However,
the current behaviour is both broken and undocumented, so maybe this is
good.
====================================================================== 

---------------------------------------------------------------------- 
 vda - 08-03-08 12:10  
---------------------------------------------------------------------- 
> The patch I attach below fixes both these issues, but does have the
disadvantage of introducing an incompatible change in behaviour.

Well, we match what GNU xargs does:

# true | xargs -e | hexdump -vC
00000000  0a                                                |.|
00000001
# true | /usr/bin/xargs -e | hexdump -vC
00000000  0a                                                |.|
00000001
# /usr/bin/xargs --version
GNU xargs version 4.1.20

> However, the current behaviour is both broken and undocumented

It is documented in GNU xargs manpage.

The bug is that busybox "xargs -e" does not switch off EOF string
detection. Fix:

diff -d -urpN busybox.5/findutils/xargs.c busybox.6/findutils/xargs.c
--- busybox.5/findutils/xargs.c 2008-07-22 01:04:20.000000000 +0200
+++ busybox.6/findutils/xargs.c 2008-08-03 21:10:47.000000000 +0200
@@ -376,6 +376,8 @@ enum {
 int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int xargs_main(int argc, char **argv)
 {
+       static const char const_eof_str[] ALIGN1 = "_";
+
        char **args;
        int i, n;
        xlist_t *list = NULL;
@@ -385,7 +387,7 @@ int xargs_main(int argc, char **argv)
        int n_max_arg;
        size_t n_chars = 0;
        long orig_arg_max;
-       const char *eof_str = "_";
+       const char *eof_str = const_eof_str;
        unsigned opt;
        size_t n_max_chars;
 #if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
@@ -396,6 +398,10 @@ int xargs_main(int argc, char **argv)

        opt = getopt32(argv, OPTION_STR, &max_args, &max_chars,
&eof_str);

+       /* -e without optional param? */
+       if ((opt & OPT_EOF_STRING) && eof_str == const_eof_str)
+               eof_str = NULL;
+
        if (opt & OPT_ZEROTERM)
                USE_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args =
process0_stdin); 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
08-01-08 00:06  Araneidae      New Issue                                    
08-01-08 00:06  Araneidae      Status                   new => assigned     
08-01-08 00:06  Araneidae      Assigned To               => BusyBox         
08-01-08 00:07  Araneidae      Issue Monitored: Araneidae                    
08-03-08 12:10  vda            Note Added: 0010174                          
======================================================================




More information about the busybox-cvs mailing list