Commit Graph

17716 Commits (e1279858394a6079be6816cbedaa3f10e74057cc)

Author SHA1 Message Date
Denys Vlasenko 3c6f6382ee libbb/dump: conditionalize code used only by xxd and od
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 12:34:11 +02:00
Denys Vlasenko aa4d303a31 od: fix default format, shrink
function                                             old     new   delta
od_main                                              556     568     +12
.rodata                                           104613  104555     -58
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 12/-58)            Total: -46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 04:27:43 +02:00
Denys Vlasenko 0c3270f7e5 od: stop printing extra trailing spaces
function                                             old     new   delta
.rodata                                           104598  104613     +15
display                                             1475    1485     +10
od_main                                              549     556      +7
rewrite                                              971     967      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 32/-4)              Total: 28 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 23:48:13 +02:00
Denys Vlasenko 6882a933cf od: implement -B
function                                             old     new   delta
.rodata                                           105305  105306      +1
od_main                                             1880    1866     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 1/-14)             Total: -13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 22:17:18 +02:00
Denys Vlasenko ce4cfc33ca od: correct -i, enable tests which pass for DESKTOP too
function                                             old     new   delta
.rodata                                           105302  105305      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 19:51:37 +02:00
Denys Vlasenko e2287f99fe od: for !DESKTOP, match output more closely to GNU coreutils 9.1, implement -s
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 17:40:20 +02:00
David Leonard 64bdd7566c od: add tests
* Added tests for od (non-DESKTOP little-endian)
* Allow 'optional' to invert meaning of a config option with '!'

Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 15:32:03 +02:00
David Leonard 2bda790fd1 od: fix -O
od with option -O (4-byte octal) was incorrectly displaying 2-byte
decimal when built without CONFIG_DESKTOP

Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 15:32:03 +02:00
Denys Vlasenko b5be8da350 hush: make "false" built-in
function                                             old     new   delta
bltins1                                              384     396     +12
builtin_false                                          -       6      +6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 18/0)               Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 15:24:56 +02:00
Denys Vlasenko 6824298ab4 hush: fix ELIF cmd1;cmd2 THEN ... not executing cmd2, closes 15571
function                                             old     new   delta
run_list                                            1012    1024     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 14:22:10 +02:00
Karsten Sperling 3e83699ce2 ash: use-after-free in bash pattern substitution
Commit daa66ed6 fixed a number of use-after-free bugs in bash pattern
substitution, however one "unguarded" STPUTC remained, which is fixed here.

function                                             old     new   delta
subevalvar                                          1564    1576     +12

Signed-off-by: Karsten Sperling <ksperling@apple.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-18 16:49:54 +02:00
Denys Vlasenko c5682813ab examples/var_service/README: fix an error
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-18 13:30:10 +02:00
Denys Vlasenko 2f663a6f7d cpio: tweak --help
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-09 20:35:16 +02:00
Denys Vlasenko dc84002a82 nslookup: code shrink
function                                             old     new   delta
send_queries                                         725     723      -2
nslookup_main                                        822     820      -2
add_query                                             89      86      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-7)               Total: -7 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-09 19:32:29 +02:00
Denys Vlasenko 62775ec4b3 nslookup: ensure unique transaction IDs for the DNS queries
Based on patch by Uwe Kleine-König.

It makes sense to actually see the nitty-gritty details of DNS
querying, so bringing in (commented-out) musl's DNS request code.

function                                             old     new   delta
nslookup_main                                        760     822     +62

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-09 19:21:45 +02:00
Denys Vlasenko 3a7f00eadc hush: add comment about abort on syntax error %{^}
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-09 14:02:06 +02:00
Denys Vlasenko 465f05a420 build system: fix "Config.in:117 error: Overlong line"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-08 12:31:34 +02:00
Denys Vlasenko 3c8e540eb7 hush: fix an interactive abort on error
function                                             old     new   delta
parse_and_run_stream                                 140     155     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-08 12:27:50 +02:00
Uwe Kleine-König 40fa8eb998 build system: Make it possible to build with 64bit time_t
On most 32bit architectures time_t (and a few other time related types)
are a signed 32bit wide integer type.
As a consequence they can only represent dates between

	Fri Dec 13 08:45:52 PM UTC 1901

(-0x80000000 seconds before Jan 1 1970) and

	Tue Jan 19 03:14:07 AM UTC 2038

(0x7fffffff seconds after Jan 1 1970). Given that some machines that are
built today have an expected lifetime of >15 years, this needs to be
extended. To to that, define the cpp symbol _TIME_BITS to 64 which
results in some magic in glibc to make time_t (and the few other time
related types) 64 bit wide.

This new switch CONFIG_TIME64 is in the spirit of CONFIG_LFS and only
expected to have the expected effect with glibc. On musl for examples
time_t already defaults to 64bit wide types.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-07 18:57:06 +02:00
Denys Vlasenko 07f8b6feac readlink: code shrink
function                                             old     new   delta
readlink_main                                        111     103      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-07 18:44:03 +02:00
Denys Vlasenko c6058d221a nmeter: improve %T fractionals display
function                                             old     new   delta
nmeter_main                                          751     786     +35

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-07 18:35:22 +02:00
Denys Vlasenko 382e163497 factor: we can pack 21, not 20, 3-bit elements into packed wheel words
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>
2023-04-23 14:02:20 +02:00
Denys Vlasenko 7ddd233c80 ip: code shrink
function                                             old     new   delta
ipaddr_list_or_flush                                1089    1079     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-23 12:37:46 +02:00
Eric Blake d2b81b3dc2 readlink: support --, -n always
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>
2023-04-16 18:01:44 +02:00
Ron Yorston 2ffd8986e2 tr: display usage for incorrect arguments
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>
2023-04-16 17:54:00 +02:00
Ron Yorston acae889dd9 ash,hush: tab completion of functions and aliases
Since commit 9e2a5668f (ash,hush: allow builtins to be tab-completed,
closes 7532) ash and hush have supported tab completion of builtins.

Other shells, bash and ksh for example, also support tab completion
of functions and aliases.

Add such support to ash and hush.

function                                             old     new   delta
ash_command_name                                       -      92     +92
hush_command_name                                      -      63     +63
ash_builtin_name                                      17       -     -17
hush_builtin_name                                     38       -     -38
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/0 up/down: 169/-55)           Total: 100 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Avi Halachmi <avihpit@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-16 17:15:05 +02:00
Denys Vlasenko 90b607d79a hush: quote variable values printed by "set" (match ash behavior)
function                                             old     new   delta
builtin_set                                          258     301     +43

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-13 09:20:24 +02:00
Denys Vlasenko 8b72877bab shuf: another tweak to COMMON_PREFIX_HACK code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-13 03:02:11 +02:00
Tomas Paukrt 7c1f975cdd build system: clean more files on make clean
Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2023-04-12 20:31:44 +02:00
Denys Vlasenko f7065aa9ae shuf: fix pfx_len calculation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12 14:56:05 +02:00
Denys Vlasenko 8696f5d380 shuf: remove redundant code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12 14:51:11 +02:00
Denys Vlasenko 238dab322a shuf: add (disabled) code to support very long numbers in -i LO-HI
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12 14:47:24 +02:00
Akos Somfai 853cfe927f lineedit: fix crash when icanon set with -echo
When icanon is set with -echo (e.g. ssh from an emacs shell) then
S.state will remain null but later it will be deferenced causing ash to
crash. Fix: additional check on state.

Signed-off-by: Akos Somfai <akos.somfai@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12 13:49:14 +02:00
Denys Vlasenko 550e6d8fbd sleep: fix error exit when called as "sh" builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12 12:23:36 +02:00
Denys Vlasenko 478b5ac2bc seq: fix yet another case of negative parameters not working
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-11 20:29:59 +02:00
Thomas Devoogdt cb57abb46f seedrng: fix for glibc <= 2.24 not providing random header
- dropped the wrong define (not sure why it was there)
 - <sys/random.h> not available if glibc <= 2.24
 - GRND_NONBLOCK not defined if <sys/random.h> not included
 - ret < 0 && errno == ENOSYS has to be true to get creditable set

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-11 13:56:12 +02:00
Denys Vlasenko 200a9669fb seedrng: fix for glibc <= 2.24 not providing getrandom()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10 17:26:04 +02:00
Tomas Paukrt 85e4805ae9 appletlib: fix "warning: unused variable applet_no"
Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10 16:56:55 +02:00
Denys Vlasenko 7362d29794 ash: fix sleep built-in not running INT trap immediately on ^C
function                                             old     new   delta
sleep_for_duration                                   169     149     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10 16:30:27 +02:00
Denys Vlasenko 611729eff3 mkfs_vfat: do not generate same volume_id when run in rapid succession
function                                             old     new   delta
mkfs_vfat_main                                      1502    1523     +21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10 14:47:38 +02:00
Denys Vlasenko 9bc2b6e884 seq: accept negative parameters
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>
2023-04-10 14:33:20 +02:00
Denys Vlasenko a26711a2d1 libbb: consolidate NOMMU fix of restoring high bit in argv[0][0]
function                                             old     new   delta
fork_or_rexec                                         46      56     +10
bootchartd_main                                     1087    1079      -8
cpio_main                                            674     661     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-21)            Total: -11 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-06 21:20:28 +02:00
Denys Vlasenko 05f2bedaeb ash: sleep builtin with no arguments should not exit
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>
2023-04-03 19:54:42 +02:00
Denys Vlasenko ff8fde111e hush: printf builtin with no arguments should not exit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03 19:29:57 +02:00
Denys Vlasenko 46e92e1e56 ash: code shrink: do not take address of prefix(), allowing it to inline
function                                             old     new   delta
getjob                                               281     285      +4
prefix                                                13       -     -13
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 4/-13)              Total: -9 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03 17:30:03 +02:00
Denys Vlasenko a33d19eba8 ash: code shrink - reuse is_prefixed_with() from libbb
function                                             old     new   delta
changepath                                            67      68      +1
legal_pathopt                                         70      66      -4
prefix                                                34      13     -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-25)             Total: -24 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03 15:19:13 +02:00
Denys Vlasenko 94780e3e8e ash: get rid of separate mail_var_path_changed flag variable
We can just clear mailtime_hash to zero and have the same effect.

function                                             old     new   delta
changemail                                             8      11      +3
mail_var_path_changed                                  1       -      -1
cmdloop                                              398     382     -16
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 3/-17)             Total: -14 bytes
   text	   data	    bss	    dec	    hex	filename
1054786	    559	   5020	1060365	 102e0d	busybox_old
1054773	    559	   5020	1060352	 102e00	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03 15:01:00 +02:00
Denys Vlasenko 7ababc3e3c ash: fix still-broken new mail detection
padvance() exit condition is return value < 0, not == 0.
After MAIL changing twice, the logic erroneously
concluded that "you have new mail".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03 14:41:01 +02:00
Denys Vlasenko 2860b2530e ash: fix broken new mail detection
Mea culpa, in "Do not allocate stack string in padvance" commit
(I left an extraneous "break" statement).

function                                             old     new   delta
cmdloop                                              329     398     +69

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03 14:01:36 +02:00
Denys Vlasenko 6748e6494c hush (NOMMU): fix LINENO in execed children
function                                             old     new   delta
hush_main                                           1815    1851     +36
re_execute_shell                                     601     635     +34
.rodata                                           102721  102726      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 75/0)               Total: 75 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-01 23:17:53 +02:00