aboutsummaryrefslogtreecommitdiff
path: root/findutils (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'busybox' into mergeRon Yorston2023-04-091-3/+36
|\
| * find: implement -okDavid Leonard2023-03-281-3/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html -ok utility_name [argument ...] ; The -ok primary shall be equivalent to -exec, except that the use of a <plus-sign> to punctuate the end of the primary expression need not be supported, and find shall request affirmation of the invocation of utility_name using the current file as an argument by writing to standard error as described in the STDERR section. If the response on standard input is affirmative, the utility shall be invoked. Otherwise, the command shall not be invoked and the value of the -ok operand shall be false. function old new delta do_exec 438 517 +79 parse_params 1833 1845 +12 static.params 288 292 +4 .rodata 100771 100775 +4 packed_usage 34543 34541 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 99/-2) Total: 97 bytes Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | xargs: kill children when interrupted by Ctrl-CRon Yorston2023-04-071-3/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A user was running the following command in a clone of the busybox-w32 repo from a busybox-w32 shell using Git for Windows: git rev-list --all | xargs git grep main.c Using Ctrl-C to interrupt the command resulted in the familiar problem that two processes ended up competing for user input: in this case the busybox-w32 shell and the Git for Windows pager, less. Make the problem go away (in this particular case) by killing all the children of xargs when it's interrupted. This is probably a sensible thing to do for other circumstances too. Adds 64-100 bytes. (GitHub issue #306)
* | xargs: omit support for -oRon Yorston2023-01-051-3/+14
| | | | | | | | | | Upstream added the -o option to reopen stdin as /dev/tty. Since /dev/tty isn't available in Microsoft Windows -o isn't applicable.
* | Merge branch 'busybox' into mergeRon Yorston2023-01-051-34/+51
|\|
| * xargs: implement -o, closes 15146Denys Vlasenko2022-12-221-34/+51
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 105225 105259 +34 d6_listen_socket 150 180 +30 packed_usage 34512 34532 +20 d6_read_interface 595 581 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 84/-14) Total: 70 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | find: -samefile requires FEATURE_EXTRA_FILE_DATARon Yorston2022-02-091-1/+1
| | | | | | | | | | Without FEATURE_EXTRA_FILE_DATA we don't have inode numbers to match so -samefile won't work.
* | Merge busybox into mergeRon Yorston2022-01-061-1/+1
|\| | | | | | | | | | | Fix merge conflict in miscutils/less.c. Use exit_SUCCESS() where possible.
| * libbb: code shrink: introduce and use [_]exit_SUCCESS()Denys Vlasenko2022-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta exit_SUCCESS - 7 +7 _exit_SUCCESS - 7 +7 run_pipe 1562 1567 +5 pseudo_exec_argv 399 400 +1 finish 86 87 +1 start_stop_daemon_main 1109 1107 -2 shutdown_on_signal 38 36 -2 runsv_main 1662 1660 -2 redirect 1070 1068 -2 read_line 79 77 -2 pause_and_low_level_reboot 54 52 -2 list_i2c_busses_and_exit 483 481 -2 less_exit 12 10 -2 identify 4123 4121 -2 grep_file 1161 1159 -2 getty_main 1519 1517 -2 fsck_minix_main 2681 2679 -2 free_session 132 130 -2 fdisk_main 4739 4737 -2 clean_up_and_exit 53 51 -2 bsd_select 1566 1564 -2 bb_daemonize_or_rexec 198 196 -2 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/17 up/down: 21/-34) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge busybox into mergeRon Yorston2021-12-271-0/+35
|\| | | | | | | Fix merge conflict in coreutils/timeout.c.
| * find: implement -samefileAaro Koskinen2021-12-171-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta parse_params 1461 1606 +145 func_samefile - 42 +42 packed_usage 34079 34102 +23 static.params 261 271 +10 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/0 up/down: 220/0) Total: 220 bytes Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-10-131-22/+125
|\|
| * find: code shrink -{m,a,c}{time,min}Denys Vlasenko2021-10-101-28/+33
| | | | | | | | | | | | | | | | | | | | | | function old new delta time_cmp - 181 +181 func_mmin 171 31 -140 func_mtime 180 34 -146 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/2 up/down: 181/-286) Total: -105 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * find: implement -amin, -atime, -cmin, and -ctimeIsmael Luceno2021-10-091-9/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta func_mtime 130 180 +50 func_mmin 121 171 +50 static.params 235 261 +26 parse_params 1435 1461 +26 packed_usage 34025 34033 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/0 up/down: 160/0) Total: 160 bytes Signed-off-by: Ismael Luceno <ismael@iodev.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * find: Unify time comparisonsIsmael Luceno2021-10-071-16/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Split the common part into a function, to be reused. The tail call is optimized, meaning now mmin/mtime just prepare arguments and jump into the common code, thus near zero overhead. This reduces code size slightly, e.g. on x86_64: text data bss dec hex filename 4806 0 0 4806 12c6 findutils/find.o.orig 4782 0 0 4782 12ae findutils/find.o Of course, the savings are even greater when implementing atime/ctime variants. Signed-off-by: Ismael Luceno <ismael@iodev.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * config: find: Fix mtime/mmin descriptionIsmael Luceno2021-10-071-2/+2
| | | | | | | | | | | | | | s/modified time/modification time/ Signed-off-by: Ismael Luceno <ismael@iodev.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-08-302-2/+2
|\|
| * Regularize "NUL terminated input" --help textsDenys Vlasenko2021-08-222-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-06-281-4/+2
|\|
| * *: more --help tweaksDenys Vlasenko2021-06-161-3/+1
| | | | | | | | | | | | | | function old new delta packed_usage 33522 33534 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * *: --help tweaksDenys Vlasenko2021-06-141-2/+2
| | | | | | | | | | | | | | function old new delta packed_usage 33589 33552 -37 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-01-141-2/+2
|\|
| * nsenter: stop option parsing on 1st non-optionDenys Vlasenko2020-12-121-1/+1
| | | | | | | | | | | | "nsenter ls -l" gives: invalid option -- 'l' Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nillyDenys Vlasenko2020-11-301-1/+1
| | | | | | | | | | | | | | | | text data bss dec hex filename 1021988 559 5052 1027599 fae0f busybox_old 1021236 559 5052 1026847 fab1f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2020-11-123-26/+36
|\|
| * libbb: shrink recursive_action() by reducing memory pressureDenys Vlasenko2020-10-012-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta recursive_action1 - 316 +316 file_action_grep 161 164 +3 add_to_prg_cache_if_socket 202 205 +3 depmod_main 509 511 +2 writeFileToTarball 488 489 +1 parse_module 281 282 +1 fileAction 207 208 +1 act 189 190 +1 add_to_dirlist 65 64 -1 writeTarFile 196 194 -2 uuidcache_init 47 45 -2 uuidcache_check_device 109 107 -2 true_action 8 6 -2 run_parts_main 310 308 -2 netstat_main 534 532 -2 lsusb_main 29 27 -2 lspci_main 45 43 -2 initial_scan 138 136 -2 grep_main 845 843 -2 find_main 482 480 -2 config_file_action 437 435 -2 chmod_main 142 140 -2 dirAction 14 10 -4 diff_main 1544 1540 -4 chown_main 154 148 -6 skip_dir 136 129 -7 dir_act 191 184 -7 recursive_action 453 69 -384 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 7/20 up/down: 328/-439) Total: -111 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tydy up a few uses of recursive_action(), no logic changesDenys Vlasenko2020-10-011-6/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xargs: fix -I SUBSTR behaviourDenys Vlasenko2020-09-301-5/+16
| | | | | | | | | | | | | | function old new delta process_stdin_with_replace 165 204 +39 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2020-08-231-15/+14
|\|
| * grep: for -L, exitcode 0 means files *without* matches were found, closes 13151Denys Vlasenko2020-08-151-15/+14
| | | | | | | | | | | | | | | | | | This is a recent change in GNU grep as well (after 3.1) function old new delta grep_file 1215 1228 +13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeFRP-3466-g53c09d0e1Ron Yorston2020-05-291-8/+16
|\|
| * grep: add proper support for pattern_listSören Tempel2020-04-301-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From POSIX.1-2008: The pattern_list's value shall consist of one or more patterns separated by <newline> characters; As such, given patterns need to be split at newline characters. Without doing so, busybox grep will interpret the newline as part of the pattern which is not in accordance with POSIX. See also: https://bugs.busybox.net/show_bug.cgi?id=12721 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * grep: Fix -f FILE when FILE is empty and -x providedGray Wolf2020-04-291-2/+3
| | | | | | | | | | | | | | | | | | | | Grep currently special-cased empty pattern file to be the same as pattern file with one empty line (empty pattern). That does mirror how GNU grep behaves, except when -x is provided. In that case .* pattern needs to be used instead. Signed-off-by: Gray Wolf <wolf@wolfsden.cz> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xargs: restore correct behaviour of -n optionRon Yorston2020-04-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | xargs: restore correct behaviour of -n optionRon Yorston2020-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge branch 'busybox' into mergeRon Yorston2020-02-151-9/+18
|\|
| * xargs: fix handling of quoted arguments, closes 11441Ron Yorston2020-01-291-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2020-01-082-3/+51
|\|
| * grep: add -RTomi Leppanen2019-11-271-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds -R option to grep similar to GNU grep. It is the same as -r but also dereferences symbolic links to directories. function old new delta grep_main 834 850 +16 packed_usage 33362 33368 +6 grep_file 1440 1441 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 23/0) Total: 23 bytes Signed-off-by: Tomi Leppanen <tomi.leppanen@jolla.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * find: implement -emptyAaro Koskinen2019-09-121-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta func_empty - 121 +121 packed_usage 33154 33167 +13 parse_params 1490 1500 +10 static.params 228 235 +7 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/0 up/down: 151/0) Total: 151 bytes Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2019-08-162-4/+4
|\|
| * libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne2019-07-022-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2019-03-121-7/+7
|\|
| * xargs: mention -E STR in --helpDenys Vlasenko2019-03-101-7/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | find: enable -xdev in default configurationRon Yorston2019-02-281-1/+1
| |
* | win32: make stat(2) fetch additional metadataRon Yorston2019-02-161-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modify the WIN32 implementation of stat(2) to fetch inode number, device id and number of hardlinks. This requires opening a handle to the target file so it will be slower. A number of features can be enabled or start to work: - tar can detect if an archive is being stored in itself; - find can support the -inum and -links options; - ls can display inode numbers; - diff can detect attempts to compare a file with itself; - du has better support for hardlinked files; - cp can detect attempts to copy a file over itself.
* | Merge branch 'busybox' into mergeRon Yorston2019-02-121-6/+15
|\|
| * grep: short-circuit -v to bail out on first matchAri Sundholm2019-01-291-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | A small optimization. There is no need to try matching the current input line against any further patterns if a match was already found and -v is specified. function old new delta grep_file 1463 1440 -23 Signed-off-by: Ari Sundholm <ari@tuxera.com> Signed-off-by: Niko Vähäsarja <niko@tuxera.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * grep: fix -x -v with certain pattern ordersAri Sundholm2019-01-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We found out that busybox -x -v is a bit broken: ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -e 'aa.*' -e '.*bb.*' aa bb cc ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -v -e 'aa.*' -e '.*bb.*' ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -e '.*aa.*' -e 'bb.*' aa bb cc ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -v -e '.*aa.*' -e 'bb.*' aa bb cc Last one is wrong. This patch fixes the issue by making sure that the variable 'found' never makes a transition from 1 to 0, as this would mean that grep previously found a match on this input line. Signed-off-by: Ari Sundholm <ari@tuxera.com> Signed-off-by: Niko Vähäsarja <niko@tuxera.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2019-01-103-4/+10
|\|