aboutsummaryrefslogtreecommitdiff
path: root/findutils/xargs.c
AgeCommit message (Collapse)Author
2020-09-30xargs: fix -I SUBSTR behaviourDenys Vlasenko
function old new delta process_stdin_with_replace 165 204 +39 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-04-29xargs: restore correct behaviour of -n optionRon Yorston
Since commit 1ff7002b1 (xargs: fix handling of quoted arguments, closes 11441) the -n option hasn't worked properly: $ echo 1 2 3 | xargs -n 1 echo 1 2 3 $ Because state is now remembered between calls to process_stdin() it's necessary to update the state before any premature return. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-01-29xargs: fix handling of quoted arguments, closes 11441Ron Yorston
As reported in bug 11441 when presented with a large number of quoted arguments xargs can return 'argument line too long': seq 10000 29999 | sed -e 's/^/"/' -e 's/$/"/' | busybox xargs echo This happens because the variant of process_stdin() which handles quoted arguments doesn't preserve state between calls. If the allowed number of characters is exceeded part way through a quoted argument the next call to process_stdin() incorrectly treats the terminating quote as a starting quote, thus quoting all of the argument separators. function old new delta process_stdin 274 303 +29 xargs_main 731 745 +14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 43/0) Total: 43 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-03-10xargs: mention -E STR in --helpDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28config: update size informationDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30xargs: fix exit code if command exits nonzero, closes 11381Denys Vlasenko
No code size change on x86. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-06tweak help textsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07xargs: use bb_ask_y_confirmation_FILE() instead of homegrown copyDenys Vlasenko
function old new delta bb_ask_y_confirmation_FILE - 83 +83 inetd_main 2033 2043 +10 udhcp_send_kernel_packet 295 301 +6 rmescapes 306 310 +4 send_tree 353 355 +2 i2cdetect_main 674 672 -2 confirm_or_abort 43 38 -5 get_terminal_width_height 242 234 -8 bb_ask_y_confirmation 76 10 -66 xargs_main 823 755 -68 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/5 up/down: 105/-149) Total: -44 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-30xargs: fix a thinko in last commitDenys Vlasenko
IF_FEATURE_XARGS_SUPPORT_PARALLEL(char *opt_a = NULL;) is replaced with IF_FEATURE_XARGS_SUPPORT_ARGS_FILE Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-29xargs: support -a FILEJohannes Schindelin
The GNU-specific option -a lets xargs read the arguments from a file rather than from stdin. This is particularly convenient when debugging in gdb interactively, and it might be of more general use. function old new delta xargs_main 788 823 +35 packed_usage 31683 31671 -12 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-24xargs: optional support for -P NUM. Closes 9511Denys Vlasenko
Based on patch by Johannes Schindelin <johannes.schindelin@gmx.de> function old new delta xargs_exec - 294 +294 packed_usage 31757 31772 +15 xargs_main 787 719 -68 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 309/-68) Total: 241 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-24xargs: code shrinkDenys Vlasenko
function old new delta xargs_main 827 787 -40 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-08getopt32: remove applet_long_optionsDenys Vlasenko
FEATURE_GETOPT_LONG made dependent on LONG_OPTS. The folloving options are removed, now LONG_OPTS enables long options for affected applets: FEATURE_ENV_LONG_OPTIONS FEATURE_EXPAND_LONG_OPTIONS FEATURE_UNEXPAND_LONG_OPTIONS FEATURE_MKDIR_LONG_OPTIONS FEATURE_MV_LONG_OPTIONS FEATURE_RMDIR_LONG_OPTIONS FEATURE_ADDGROUP_LONG_OPTIONS FEATURE_ADDUSER_LONG_OPTIONS FEATURE_HWCLOCK_LONG_OPTIONS FEATURE_NSENTER_LONG_OPTS FEATURE_CHCON_LONG_OPTIONS FEATURE_RUNCON_LONG_OPTIONS They either had a small number of long options, or their long options are essential. Example: upstream addgroup and adduser have ONLY longopts, we should probably go further and get rid of non-standard short options. To this end, make addgroup and adduser "select LONG_OPTS". We had this breakage caused by us even in our own package! #if ENABLE_LONG_OPTS || !ENABLE_ADDGROUP /* We try to use --gid, not -g, because "standard" addgroup * has no short option -g, it has only long --gid. */ argv[1] = (char*)"--gid"; #else /* Breaks if system in fact does NOT use busybox addgroup */ argv[1] = (char*)"-g"; #endif xargs: its lone longopt no longer depends on DESKTOP, only on LONG_OPTS. hwclock TODO: get rid of incompatible -t, -l aliases to --systz, --localtime Shorten help texts by omitting long option when short opt alternative exists. Reduction of size comes from the fact that store of an immediate (an address of longopts) to a fixed address (global variable) is a longer insn than pushing that immediate or passing it in a register. This effect is CPU-agnostic. function old new delta getopt32 1350 22 -1328 vgetopt32 - 1318 +1318 getopt32long - 24 +24 tftpd_main 562 567 +5 scan_recursive 376 380 +4 collect_cpu 545 546 +1 date_main 1096 1095 -1 hostname_main 262 259 -3 uname_main 259 255 -4 setpriv_main 362 358 -4 rmdir_main 191 187 -4 mv_main 562 558 -4 ipcalc_main 548 544 -4 ifenslave_main 641 637 -4 gzip_main 192 188 -4 gunzip_main 77 73 -4 fsfreeze_main 81 77 -4 flock_main 318 314 -4 deluser_main 337 333 -4 cp_main 374 370 -4 chown_main 175 171 -4 applet_long_options 4 - -4 xargs_main 894 889 -5 wget_main 2540 2535 -5 udhcpc_main 2767 2762 -5 touch_main 436 431 -5 tar_main 1014 1009 -5 start_stop_daemon_main 1033 1028 -5 sed_main 682 677 -5 script_main 1082 1077 -5 run_parts_main 330 325 -5 rtcwake_main 459 454 -5 od_main 2169 2164 -5 nl_main 201 196 -5 modprobe_main 773 768 -5 mkdir_main 160 155 -5 ls_main 568 563 -5 install_main 773 768 -5 hwclock_main 411 406 -5 getopt_main 622 617 -5 fstrim_main 256 251 -5 env_main 198 193 -5 dumpleases_main 635 630 -5 dpkg_main 3991 3986 -5 diff_main 1355 1350 -5 cryptpw_main 233 228 -5 cpio_main 593 588 -5 conspy_main 1135 1130 -5 chpasswd_main 313 308 -5 adduser_main 887 882 -5 addgroup_main 416 411 -5 ftpgetput_main 351 345 -6 get_terminal_width_height 242 234 -8 expand_main 690 680 -10 static.expand_longopts 18 - -18 static.unexpand_longopts 27 - -27 mkdir_longopts 28 - -28 env_longopts 30 - -30 static.ifenslave_longopts 34 - -34 mv_longopts 46 - -46 static.rmdir_longopts 48 - -48 packed_usage 31739 31687 -52 ------------------------------------------------------------------------------ (add/remove: 2/8 grow/shrink: 3/49 up/down: 1352/-1840) Total: -488 bytes text data bss dec hex filename 915681 485 6880 923046 e15a6 busybox_old 915428 485 6876 922789 e14a5 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21config: deindent all help textsDenys Vlasenko
Those two spaces after tab have no effect, and always a nuisance when editing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18Update menuconfig items with approximate applet sizesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21*: add most of the required setup_common_bufsiz() callsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for itDenys Vlasenko
The config item is FEATURE_USE_BSS_TAIL. When it is off (default): function old new delta read_config 210 228 +18 doCommands 2279 2294 +15 ipneigh_list_or_flush 763 772 +9 ipaddr_list_or_flush 1256 1261 +5 display_process_list 1301 1306 +5 conspy_main 1378 1383 +5 do_lzo_compress 352 355 +3 do_lzo_decompress 565 567 +2 push 46 44 -2 inetd_main 2136 2134 -2 uevent_main 421 418 -3 addLines 97 92 -5 bb_common_bufsiz1 8193 1024 -7169 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181) Total: -7119 bytes text data bss dec hex filename 829850 4086 9080 843016 cdd08 busybox_old 829901 4086 1904 835891 cc133 busybox_unstripped FEATURE_USE_BSS_TAIL=y: read_config 210 228 +18 doCommands 2279 2294 +15 ipneigh_list_or_flush 763 772 +9 ipaddr_list_or_flush 1256 1261 +5 display_process_list 1301 1306 +5 conspy_main 1378 1383 +5 do_lzo_compress 352 355 +3 do_lzo_decompress 565 567 +2 inetd_main 2136 2134 -2 bb_common_bufsiz1 8193 - -8193 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195) Total: -8133 bytes text data bss dec hex filename 829850 4086 9080 843016 cdd08 busybox_old 829911 4086 880 834877 cbd3d busybox_unstripped FIXME: setup_common_bufsiz() calls are missing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24xargs: make -I imply -rAaro Koskinen
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>
2015-10-08join some common strings, -400 bytesDenys Vlasenko
function old new delta print_intel_cstates 499 511 +12 file_insert 355 364 +9 dpkg_main 2944 2940 -4 ifenslave_main 645 640 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 21/-9) Total: 12 bytes text data bss dec hex filename 937564 932 17676 956172 e970c busybox_old 937164 932 17676 955772 e957c busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-25typo fixesManinder Singh
Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22find: use sysconf(_SC_ARG_MAX) to determine the command-line size limitDenys Vlasenko
The find utility uses a hardcoded value of 32 * 1024 as the limit of the command-line length when calling 'find -exec ... {} +'. This results in over 4 times more execve() calls than in coreutils' find. This patch uses the limit defined in system headers. Based on the patch by Bartosz Golaszewski <bartekgola@gmail.com>. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-27xargs: fix compilation breakageDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-27xargs: add support for -I and -i. Closes 493Denys Vlasenko
function old new delta process_stdin_with_replace - 195 +195 xmalloc_substitute_string - 145 +145 xargs_main 808 884 +76 count_strstr - 45 +45 packed_usage 29580 29571 -9 parse_params 1445 1416 -29 func_exec 285 138 -147 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 1/3 up/down: 461/-185) Total: 276 bytes text data bss dec hex filename 922156 932 17692 940780 e5aec busybox_old 922440 932 17692 941064 e5c08 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05*: remove "Options:" string from help textsDenys Vlasenko
function old new delta packed_usage 28706 28623 -83 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-03xargs: support --no-run-if-empty (synonym to -r)Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-18mass removal of underscores from _BB_DIR_foo and _BB_SUID_fooDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16*: make GNU licensing statement forms more regularDenys Vlasenko
This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-19xargs: bump default -sNUM up to 32k. Use sysconf() to trim it down if necessaryDenys Vlasenko
function old new delta xargs_main 819 830 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-15findutils/*: move usage and applet bits to *.c filesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-15xargs: another code shrinkDenys Vlasenko
function old new delta process0_stdin 117 103 -14 process_stdin 336 314 -22 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-15xargs: trivial code shrinkDenys Vlasenko
function old new delta xargs_main 807 787 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-14xargs: trivial code shrinkDenys Vlasenko
function old new delta process_stdin 343 336 -7 process0_stdin 124 117 -7 xargs_main 807 787 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-14xargs: simplify logicDenys Vlasenko
Removed double-buffering in a linked list. function old new delta store_param - 56 +56 xargs_main 871 840 -31 process_stdin 458 396 -62 process0_stdin 267 143 -124 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 56/-217) Total: -161 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-13xargs: fix accounting of -sNUMDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-13xargs: make -s NUM accept practically unlimited rangeDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-13xargs: code shrink -15 bytesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06pipe_progress: make it independent of printf machineryDenys Vlasenko
function old new delta bb_putchar_stderr - 24 +24 ParseField 494 471 -23 progress_meter 212 188 -24 xargs_main 888 842 -46 pipe_progress_main 151 105 -46 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/4 up/down: 24/-139) Total: -115 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06remove defconfig. Now "make defconfig" simply uses defaults from Config.inDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-09make it possible to keep Config/Kbuild snippets in *.c filesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-09xargs: do not decrease orig_arg_max to negative valuesDenys Vlasenko
Based on patch by Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-18*: code shrink and better "died from signal" reporting from wait4pidDenys Vlasenko
function old new delta parse 964 967 +3 udhcp_run_script 670 665 -5 singlemount 911 906 -5 mount_it_now 360 355 -5 inotifyd_main 521 516 -5 xspawn 21 - -21 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/4 up/down: 3/-41) Total: -38 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-13*: use "can't" instead of "cannot"Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-02*: introduce and use ffulsh_all()Denys Vlasenko
function old new delta buffer_fill_and_print 179 196 +17 fflush_all - 9 +9 spawn 87 92 +5 rtcwake_main 455 453 -2 ... alarm_intr 93 84 -9 readcmd 1072 1062 -10 bb_ask 345 333 -12 more_main 845 832 -13 flush_stdout_stderr 42 23 -19 xfflush_stdout 27 - -27 flush_stderr 30 - -30 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397) Total: -366 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-04-21*: mass renaming of USE_XXXX to IF_XXXXDenis Vlasenko
and SKIP_XXXX to IF_NOT_XXXX - the second one was especially badly named. It was not skipping anything!
2008-08-04xargs: fix -e default to match newer GNU xargs, add SUS mandated -E.Denis Vlasenko
closes bug 4414
2008-08-03xargs: fix xargs -e; added test for thatDenis Vlasenko
2008-07-21libbb: [x]fopen_for_{read,write} introduced and used.Denis Vlasenko
(by Valdimir) function old new delta config_open2 - 41 +41 config_read 507 542 +35 find_pair 169 187 +18 fopen_for_write - 14 +14 fopen_for_read - 14 +14 find_main 406 418 +12 xfopen_for_write - 10 +10 xfopen_for_read - 10 +10 popstring 134 140 +6 parse_inittab 396 401 +5 next_token 923 928 +5 pack_gzip 1659 1661 +2 bb__parsespent 117 119 +2 fallbackSort 1719 1717 -2 evalvar 1376 1374 -2 qrealloc 36 33 -3 ... ... ... ... singlemount 4579 4569 -10 process_stdin 443 433 -10 patch_main 1111 1101 -10 ifupdown_main 2175 2165 -10 file_action_grep 90 80 -10 uuidcache_init 649 637 -12 hush_main 797 785 -12 read_config 230 217 -13 dpkg_main 3835 3820 -15 read_line_input 3134 3110 -24 sysctl_main 232 203 -29 config_open 40 10 -30 WARN_BAD_LINE 44 - -44 login_main 1714 1575 -139 ------------------------------------------------------------------------------ (add/remove: 5/1 grow/shrink: 8/74 up/down: 174/-737) Total: -563 bytes
2008-07-05*: rename ATTRIBUTE_XXX to just XXX.Denis Vlasenko
2008-06-15*: use llist_pop for traverse-and-free list operationDenis Vlasenko
function old new delta append_file_list_to_list 109 111 +2 udhcpc_main 2414 2413 -1 run_parts_main 325 324 -1 od_main 2324 2323 -1 getopt_main 709 707 -2 env_main 253 251 -2 sed_main 659 656 -3 ps_main 522 519 -3 traceroute_main 3960 3954 -6 sort_main 844 838 -6 diff_main 866 858 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/10 up/down: 2/-33) Total: -31 bytes