summaryrefslogtreecommitdiff
path: root/coreutils
Commit message (Collapse)AuthorAgeFilesLines
* readlink: code shrinkDenys Vlasenko2023-05-071-5/+4
| | | | | | | function old new delta readlink_main 111 103 -8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* factor: we can pack 21, not 20, 3-bit elements into packed wheel wordsDenys Vlasenko2023-04-231-36/+35
| | | | | | | | | | function old new delta packed_wheel 192 184 -8 factor_main 171 163 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-16) Total: -16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* readlink: support --, -n alwaysEric Blake2023-04-161-17/+12
| | | | | | | | | | | | | | | | | | | | | | | POSIX will be standardizing readlink (just the -n option) and realpath (just -E and -e options): https://www.austingroupbugs.net/view.php?id=1457 Change things for readlink so that the POSIX-mandated -n and -- work even when disabling the non-standard (and partially non-working) -f when FEATURE_READLINK_FOLLOW is clear. POSIX also wants readlink to be verbose by default (if the argument is not a symlink, readlink must output a diagnostic); I did NOT address that one, because I'm waiting to see what the GNU Coreutils folks do: https://lists.gnu.org/archive/html/bug-coreutils/2023-03/msg00035.html Partial fix for https://bugs.busybox.net/show_bug.cgi?id=15466 function old new delta packed_usage 34538 34557 +19 Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tr: display usage for incorrect argumentsRon Yorston2023-04-161-1/+1
| | | | | | | | | | | | | tr must have one or two non-option arguments. Display the usage message if any other number is present. function old new delta .rodata 108389 108392 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 3/0) Total: 3 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: another tweak to COMMON_PREFIX_HACK codeDenys Vlasenko2023-04-131-8/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: fix pfx_len calculationDenys Vlasenko2023-04-121-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: remove redundant codeDenys Vlasenko2023-04-121-2/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: add (disabled) code to support very long numbers in -i LO-HIDenys Vlasenko2023-04-121-6/+58
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sleep: fix error exit when called as "sh" builtinDenys Vlasenko2023-04-121-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* seq: fix yet another case of negative parameters not workingDenys Vlasenko2023-04-111-2/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* seq: accept negative parametersDenys Vlasenko2023-04-101-2/+21
| | | | | | | | | | function old new delta seq_main 429 476 +47 packed_usage 34557 34538 -19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 47/-19) Total: 28 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: sleep builtin with no arguments should not exitDenys Vlasenko2023-04-031-1/+14
| | | | | | | | | | function old new delta sleep_main 116 143 +27 .rodata 105245 105268 +23 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 50/0) Total: 50 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: printf builtin with no arguments should not exitDenys Vlasenko2023-04-031-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mv: fix error in !VERBOSE configsDenys Vlasenko2023-01-021-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Fix non-Linux buildsSamuel Thibault2022-11-291-2/+18
| | | | | | | | | | | Various tools are Linuxish and should thus only attempted to build on Linux only. Some features are also Linux-only. Also, libresolv is used on all GNU platforms, notably GNU/Hurd and GNU/kfreeBSD. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: style fixDenys Vlasenko2022-08-302-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: optional sleep builtinShawn Landden2022-08-271-0/+1
| | | | | | | | | | | | function old new delta sleepcmd - 10 +10 builtintab 352 360 +8 .rodata 105264 105271 +7 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 25/0) Total: 25 bytes Signed-off-by: Shawn Landden <shawnlandden@tutanota.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sort: fix sort -s -u, closes 14871Denys Vlasenko2022-07-291-4/+5
| | | | | | | function old new delta sort_main 851 856 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sort: fix -k2M (wasn't skipping leading whitespace)Denys Vlasenko2022-07-291-2/+2
| | | | | | | function old new delta compare_keys 848 862 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shaNNNsum: accept one-space "HASH FILENAME" format for -c, closes 14866Denys Vlasenko2022-07-111-5/+8
| | | | | | | function old new delta md5_sha1_sum_main 496 501 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tsort: new appletDavid Leonard2022-05-021-0/+188
| | | | | | | | | | | | | | function old new delta tsort_main - 578 +578 .rodata 104884 104906 +22 applet_names 2759 2765 +6 applet_main 1596 1600 +4 packed_usage 34290 34288 -2 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/1 up/down: 610/-2) Total: 608 bytes Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: slap on a few ALIGN_PTR where appropriateDenys Vlasenko2022-02-061-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: slap on a few ALIGN* where appropriateDenys Vlasenko2022-02-061-1/+1
| | | | | | | | | | | | | | The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map" function old new delta .rodata 108586 108460 -126 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126) Total: -126 bytes text data bss dec hex filename 970412 4219 1848 976479 ee65f busybox_old 970286 4219 1848 976353 ee5e1 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: shrink lineedit_read_key()Denys Vlasenko2022-01-181-3/+3
| | | | | | | function old new delta lineedit_read_key 237 231 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ls: implement ls -sh (human-readable allocated blocks)Denys Vlasenko2022-01-081-3/+10
| | | | | | | function old new delta display_single 979 1018 +39 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* XXXsum: handle binary sums with " " in the pathEmanuele Giacomelli2022-01-081-6/+4
| | | | | | | | | | | | | | | | | | | | If a line specifies a binary checksum whose path contains two adjacent spaces, when checking digests with -c the two spaces will be used as the separator between the digest and the pathname instead of " *", as shown: $ echo foo > "/tmp/two spaces" $ md5sum -b "/tmp/two spaces" # This is GNU md5sum d3b07384d113edec49eaa6238ad5ff00 */tmp/two spaces $ md5sum -b "/tmp/two spaces" | ./busybox md5sum -c md5sum: can't open 'spaces': No such file or directory spaces: FAILED md5sum: WARNING: 1 of 1 computed checksums did NOT match function old new delta md5_sha1_sum_main 503 496 -7 Signed-off-by: Emanuele Giacomelli <emanuele.giacomelli@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sort: support -hDenys Vlasenko2022-01-051-31/+64
| | | | | | | | | | | | | | function old new delta static.scale_suffix - 62 +62 .rodata 104304 104336 +32 compare_keys 820 848 +28 packed_usage 34159 34184 +25 static.suffix - 9 +9 sort_opt_str 37 38 +1 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/0 up/down: 157/0) Total: 157 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sort: fix -s -r interaction: 'stable' order is not affected by -rDenys Vlasenko2022-01-041-1/+3
| | | | | | | function old new delta compare_keys 818 820 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS)Denys Vlasenko2022-01-049-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | function old new delta fflush_stdout_and_exit_SUCCESS - 7 +7 xxd_main 890 888 -2 vlock_main 353 351 -2 uuencode_main 318 316 -2 uniq_main 427 425 -2 uname_main 250 248 -2 sort_main 853 851 -2 shuf_main 500 498 -2 route_main 238 236 -2 readlink_main 113 111 -2 nice_main 156 154 -2 last_main 957 955 -2 ipcs_main 960 958 -2 env_main 209 207 -2 chrt_main 464 462 -2 cal_main 921 919 -2 baseNUM_main 650 648 -2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/16 up/down: 7/-32) Total: -25 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* md5/shaXsum: use FEATURE_COPYBUF_KB to size the buffer instead of fixed 4kDenys Vlasenko2022-01-041-7/+14
| | | | | | | | | | | | | function old new delta md5_sha1_sum_main 536 565 +29 hash_file 419 401 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 29/-18) Total: 11 bytes In my test, for unrolled sha1, COPYBUF_KB=64 increases throughput from 367 MB/s to 457 MB/s. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* echo: add FIXME commentDenys Vlasenko2021-12-291-0/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* timeout: add support for "timeout -k KILL_SECS"Matthew Slowe2021-12-171-11/+32
| | | | | | | | | | | | | function old new delta timeout_main 307 373 +66 timeout_wait - 42 +42 .rodata 104201 104203 +2 packed_usage 34097 34096 -1 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/1 up/down: 110/-1) Total: 109 bytes Signed-off-by: Matthew Slowe <foo@mafoo.org.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* printf: allow 0 as a flag and allow multiple flagsRon Yorston2021-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | The '%' character in a format specification may be followed by one or more flags from the list "+- #0". BusyBox printf didn't support the '0' flag or allow multiple flags to be provided. As a result the formats '%0*d' and '%0 d' were considered to be invalid. The lack of support for '0' was pointed out by Andrew Snyder on the musl mailing list: https://www.openwall.com/lists/musl/2021/12/14/2 function old new delta printf_main 860 891 +31 .rodata 99281 99282 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0) Total: 32 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* uudecode: special-case "/dev/stdout", closes 14241Denys Vlasenko2021-12-121-1/+10
| | | | | | | function old new delta uudecode_main 295 322 +27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* config system: move some options closer to relevalnt tool subdirectoriesDenys Vlasenko2021-10-122-4/+35
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Make const ptr assign as function call in clangYU Jincheng2021-10-091-1/+1
| | | | | | | | - This can act as memory barrier in clang to avoid read before assign of a const ptr Signed-off-by: LoveSy <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mktemp: add --tmpdir optionAndrej Valek2021-10-081-1/+15
| | | | | | | | | | | | | | | | | | Make mktemp more compatible with coreutils. - add "--tmpdir" option - add long variants for "d,q,u" options Note: Upstream ca-certificate update script started using this option. function old new delta .rodata 104179 104219 +40 mktemp_main 186 194 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 48/0) Total: 48 bytes Signed-off-by: Andrej Valek <andrej.valek@siemens.com> Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: generalize "const trick"YU Jincheng2021-10-071-3/+2
| | | | | | | | While at it, change all "__asm__" to "asm" Co-authored-by: canyie <31466456+canyie@users.noreply.github.com> Signed-off-by: YU Jincheng <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: clarify what bb_mode_string() generatesDenys Vlasenko2021-09-171-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: eliminate a static data array in bb_mode_string()Denys Vlasenko2021-09-173-4/+8
| | | | | | | | | | | | | | | | function old new delta print_stat 861 869 +8 header_verbose_list_ar 73 77 +4 display_single 975 979 +4 header_verbose_list 237 239 +2 bb_mode_string 124 115 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 18/-9) Total: 9 bytes text data bss dec hex filename 1043136 559 5052 1048747 1000ab busybox_old 1043153 559 5020 1048732 10009c busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* chmod: correctly report changed modesDenys Vlasenko2021-09-171-1/+2
| | | | | | | | | | | Chmod used to incorrectly report as changed even files for which the mode did not change. This was caused by extra bits in the st_mode, that were not present when parsed from passed argument in the form of octal number. Patch by Wolf <wolf@wolfsden.cz>. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* date,touch: allow timezone offsets in datesRon Yorston2021-09-172-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | Allow ISO 8601 style dates to include a timezone offset. Like the '@' format these dates aren't relative to the user's current timezone and shouldn't be subject to DST adjustment. - The implementation uses the strptime() '%z' format specifier. This an extension which may not be available so the use of timezones is a configuration option. - The 'touch' applet has been updated to respect whether DST adjustment is required, matching 'date'. function old new delta parse_datestr 624 730 +106 static.fmt_str 106 136 +30 touch_main 388 392 +4 date_main 818 819 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 141/0) Total: 141 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* df: "support" -H as an alias of -hDenys Vlasenko2021-09-111-11/+15
| | | | | | | | | | function old new delta df_main 1065 1068 +3 .rodata 104232 104233 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 4/0) Total: 4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* basename: implement -a and -s SUFFIXDenys Vlasenko2021-09-091-24/+38
| | | | | | | | | | | function old new delta basename_main 145 207 +62 packed_usage 33914 33950 +36 .rodata 104241 104250 +9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 107/0) Total: 107 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: add a TODO, code shrinkDenys Vlasenko2021-09-071-10/+14
| | | | | | | function old new delta shuf_main 501 500 -1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: make -i 99999999990-100000000000 work even on 32 bitsDenys Vlasenko2021-09-041-26/+19
| | | | | | | | | | function old new delta shuf_main 443 501 +58 .rodata 104238 104245 +7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 65/0) Total: 65 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: in -i RANGE, accept numbers up to width of pointersDenys Vlasenko2021-08-291-10/+28
| | | | | | | | function old new delta .rodata 108468 108474 +6 shuf_main 555 542 -13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: with -i LOW-HIGH, do not allow any argv'sDenys Vlasenko2021-08-231-0/+3
| | | | | | | function old new delta shuf_main 436 441 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: tweak --help textDenys Vlasenko2021-08-231-4/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shuf: speed-up when limited output is requestedRon Yorston2021-08-221-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | A user noted that the following command was slower than they expected: busybox shuf -i "1500000000-$(date +%s)" -n 5 At time of writing the range contains 128 million values. On my system this takes 7.7s whereas 'shuf' from coreutils takes a handful of milliseconds. Optimise BusyBox 'shuf' for cases where -n is specified by stopping shuffling once the required number of lines have been processed. On my system the time for the example is reduced to 0.4s. function old new delta shuf_main 520 540 +20 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 20/0) Total: 20 bytes v2: Code shrink. Since outlines <= numlines: - the loop in shuffle_lines() only needs to test the value of outlines; - shuffle_lines() can be called unconditionally. Update timing to allow for the 13 million seconds elapsed since v1. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>