Denys Vlasenko
92ab29fcf0
awk: implement -E; do not reorder -f and -e
...
function old new delta
awk_main 843 891 +48
next_input_file 243 261 +18
packed_usage 34631 34638 +7
.rodata 105391 105390 -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 73/-1) Total: 72 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-10-02 15:24:06 +02:00
Nero
6d22c9abc2
install: Fix chown resetting suid/sgid bits from chmod
...
Since Linux 2.2.13, chown(2) resets the suid/gid bits for all users.
This patch changes the ordering so that chmod gets called after chown.
This behavior follows GNU coreutils.
Signed-off-by: Nero <nero@w1r3.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-10-02 14:26:27 +02:00
Denys Vlasenko
791b222dd5
sleep: fix "sleep -- ARGS"
...
function old new delta
sleep_main 116 119 +3
printf_main 860 837 -23
single_argv 50 25 -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 3/-48) Total: -45 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-10-02 13:56:32 +02:00
Ron Yorston
2cc9d436e8
tsort: avoid use-after-free
...
When the input data contained a cycle it was possible for tsort to
attempt to access freed nodes. This sometimes resulted in the
test case 'echo a b b a | tsort' crashing.
Don't free nodes when they're removed from the graph.
function old new delta
tsort_main 621 596 -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-25) Total: -25 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-08-31 09:41:53 +02:00
zhuyan
ed4a24dfd1
ash: initialize basepf.buf in ash
...
When I planned to print the command in read_line_input, I found that after
the system started, the command printed for the first time was always
garbled.
After analysis, it is found that in the init() function of ash, the
variable basepf.buf is not initialized after applying for memory, resulting
in garbled initial data. Then assign it to the global variable
g_parsefile->buf in ash.c, and then pass g_parsefile->buf to the parameter
command of the function read_line_input in the function preadfd(), and
finally cause it to be garbled when the command is printed by
read_line_input.
The call stack is as follows:
#0 read_line_input (st=0xb6fff220, prompt=0xb6ffc910 "\\[\\033[32m\\]\\h \\w\\[\\033[m\\] \\$ ", command=command@entry=0xb6ffc230 "P\325\377\266P\325\377\266", maxsize=maxsize@entry=1024) at libbb/lineedit.c:2461
#1 0x0043ef8c in preadfd () at shell/ash.c:10812
#2 preadbuffer () at shell/ash.c:10914
#3 pgetc () at shell/ash.c:10997
#4 0x00440c20 in pgetc_eatbnl () at shell/ash.c:11039
#5 0x00440cbc in xxreadtoken () at shell/ash.c:13157
#6 0x00440f40 in readtoken () at shell/ash.c:13268
#7 0x00441234 in list (nlflag=nlflag@entry=1) at shell/ash.c:11782
#8 0x004420e8 in parsecmd (interact=<optimized out>) at shell/ash.c:13344
#9 0x00442c34 in cmdloop (top=top@entry=1) at shell/ash.c:13549
#10 0x00444e4c in ash_main (argc=<optimized out>, argv=0x444e4c <ash_main+1328>) at shell/ash.c:14747
#11 0x00407954 in run_applet_no_and_exit (applet_no=9, name=<optimized out>, argv=0xbefffd34) at libbb/appletlib.c:1024
#12 0x00407b68 in run_applet_and_exit (name=0xbefffe56 "ash", argv=0x9) at libbb/appletlib.c:1047
#13 0x00407f88 in main (argc=<optimized out>, argv=0xbefffd34) at libbb/appletlib.c:1181
Fixes: 82dd14a510
("ash: use CONFIG_FEATURE_EDITING_MAX_LEN")
Signed-off-by: zhuyan <zhuyan34@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-08-31 02:20:19 +02:00
Denys Vlasenko
8f0845cad7
libbb: rename source files, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-18 16:41:12 +02:00
Denys Vlasenko
c484846c44
introduce and use exitcode_t
...
function old new delta
strings_main 422 420 -2
setfattr_main 175 173 -2
brctl_main 1548 1546 -2
makedevs_main 979 975 -4
rev_main 337 332 -5
getfattr_main 307 302 -5
cut_main 1201 1196 -5
cksum_main 398 393 -5
umount_main 573 565 -8
ln_main 516 508 -8
expand_main 660 652 -8
df_main 1068 1060 -8
renice_main 346 332 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/13 up/down: 0/-76) Total: -76 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-17 17:29:36 +02:00
Denys Vlasenko
a6a102ec4c
getfattr: fix "getfattr NOTEXIST" - now prints error msg
...
function old new delta
getfattr_main 309 307 -2
.rodata 105395 105391 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-17 09:36:17 +02:00
YU Jincheng
cf809e2f2d
getfattr: new applet
...
function old new delta
getfattr_main - 309 +309
print_attr - 115 +115
packed_usage 34576 34631 +55
.rodata 105349 105395 +46
lgetxattr - 41 +41
getxattr - 41 +41
llistxattr - 35 +35
listxattr - 35 +35
applet_names 2806 2815 +9
applet_main 1620 1624 +4
------------------------------------------------------------------------------
(add/remove: 7/0 grow/shrink: 4/0 up/down: 690/0) Total: 690 bytes
Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-16 14:40:44 +02:00
Denys Vlasenko
ab755f4925
hwclock: force LONG_OPTS, stop accepting non-compatible -t
...
function old new delta
hwclock_main 576 579 +3
.rodata 105404 105349 -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 3/-55) Total: -52 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-14 16:37:24 +02:00
Andrej Picej
d70256a5c7
hwclock: add get/set parameters option
...
In kernel 5.16 special ioctls were introduced to get/set RTC parameters.
Add option to get/set parameters into busybox version of hwclock.
Implementation is similar to the one already used in linux-utils hwclock
tool.
Example of parameter get use:
$ hwclock -g 2
The RTC parameter 0x2 is set to 0x2.
$ hwclock --param-get bsm
The RTC parameter 0x2 is set to 0x2.
Example of parameter set use:
$ hwclock -p 2=1
The RTC parameter 0x2 will be set to 0x1.
$ hwclock -p bsm=2
The RTC parameter 0x2 will be set to 0x2.
function old new delta
hwclock_main 298 576 +278
.rodata 105231 105400 +169
packed_usage 34541 34576 +35
static.hwclock_longopts 60 84 +24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 506/0) Total: 506 bytes
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-12 16:27:49 +02:00
Denys Vlasenko
9fc5933b10
ntpd: fix a warning on 32-bit arch build
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-10 17:29:38 +02:00
Denys Vlasenko
69d33db445
i2ctransfer: fix build warning
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-10 17:27:26 +02:00
Denys Vlasenko
5353df91cb
Update applet size estimates
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-10 17:25:21 +02:00
Denys Vlasenko
a9047e0980
ash: tweak comments, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-10 12:02:34 +02:00
Denys Vlasenko
ae351311da
ash: remove "volatile" specifier from suppress_int
...
function old new delta
aliascmd 274 278 +4
signal_handler 81 80 -1
static.redirectsafe 144 141 -3
unwindlocalvars 219 215 -4
trapcmd 333 329 -4
setvar 164 160 -4
setpwd 167 163 -4
setinputfile 216 212 -4
setcmd 76 72 -4
readcmd 221 217 -4
raise_exception 26 22 -4
out2str 37 33 -4
out1str 32 28 -4
freejob 89 85 -4
forkchild 616 612 -4
fg_bgcmd 298 294 -4
expandarg 949 945 -4
evaltree 753 749 -4
evalsubshell 173 169 -4
evalpipe 346 342 -4
evalfun 408 404 -4
cdcmd 699 695 -4
ash_main 1240 1236 -4
__pgetc 589 585 -4
unaliascmd 152 147 -5
unalias 51 46 -5
umaskcmd 253 248 -5
stalloc 97 92 -5
shiftcmd 144 139 -5
setinputstring 73 68 -5
redirect 1068 1063 -5
recordregion 81 76 -5
pushstring 160 155 -5
popstring 120 115 -5
popstackmark 69 64 -5
popredir 123 118 -5
popfile 110 105 -5
out1fmt 45 40 -5
newline_and_flush 39 34 -5
ifsfree 66 61 -5
growstackblock 146 141 -5
freestrings 95 90 -5
fmtstr 59 54 -5
flush_stdout_stderr 23 18 -5
dowait 577 572 -5
delete_cmd_entry 52 47 -5
clearcmdentry 98 93 -5
ash_arith 79 74 -5
argstr 1404 1399 -5
evalcommand 1523 1515 -8
removerecordregions 219 209 -10
mklocal 284 274 -10
find_command 893 883 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/52 up/down: 4/-251) Total: -247 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-10 11:13:51 +02:00
Denys Vlasenko
5e0411a7fb
ash: disable sleep as builtin, closes 15619
...
Has a few annoying problems:
* sleepcmd() -> sleep_main(), the parsing of bad arguments exits the shell.
* sleep_for_duration() in sleep_main() has to be interruptible for
^C traps to work, which may be a problem for other users
of sleep_for_duration().
* BUT, if sleep_for_duration() is interruptible, then SIGCHLD interrupts it
as well (try "/bin/sleep 1 & sleep 10").
* sleep_main() must not allocate anything as ^C in ash longjmp's.
(currently, allocations are only on error paths, in message printing).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-10 10:53:23 +02:00
Yousong Zhou
6ce1dc2e91
libiproute: fix filtering ip6 route by table id
...
Otherwise
- "ip -6 route show" shows routes from all tables
- "ip -6 route show table 200" shows nothing
function old new delta
print_route 1962 1941 -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-21) Total: -21 bytes
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-09 20:26:23 +02:00
Denys Vlasenko
e41e481fd5
hush: fix a compile failure
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-08 17:57:42 +02:00
Denys Vlasenko
07a95cfcab
ash: disable check for "good" function name, bash does not check this
...
function old new delta
.rodata 105304 105261 -43
parse_command 1696 1633 -63
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-106) Total: -106 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-04 14:38:25 +02:00
Denys Vlasenko
e5692e2342
hush: quote values in "readonly" output
...
function old new delta
builtin_readonly 61 107 +46
builtin_export 140 145 +5
.rodata 105321 105304 -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 51/-17) Total: 34 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-03 14:30:59 +02:00
Denys Vlasenko
cc9543fed1
shell/math: avoid $((3**999999999999999999)) to take years
...
function old new delta
arith_apply 991 1030 +39
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-02 19:32:12 +02:00
Denys Vlasenko
045924ed7d
shell/math: do not accept $((36#@))
...
function old new delta
parse_with_base 170 174 +4
arith_apply 996 991 -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-5) Total: -1 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-02 17:58:20 +02:00
Denys Vlasenko
38f769ab4e
shell/math: code shrink
...
function old new delta
arith_apply 999 996 -3
evaluate_string 1295 1291 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-7) Total: -7 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-30 19:16:41 +02:00
Denys Vlasenko
6a0ba67382
shell/math: code shrink
...
function old new delta
arith_apply 1023 996 -27
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-29 11:01:50 +02:00
Denys Vlasenko
800207b90a
shell/math: code shrink
...
function old new delta
arith_apply 1015 1023 +8
evaluate_string 1309 1295 -14
.rodata 105344 105321 -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 8/-37) Total: -29 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-28 14:18:35 +02:00
Denys Vlasenko
e619a25a55
shell/math: improve comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-26 11:08:40 +02:00
Denys Vlasenko
5d8f8570c0
shell/math: rename TOK_NUM to TOK_VALUE, improve comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-26 10:02:54 +02:00
Denys Vlasenko
c1c267fd36
shell/math: bash-compatible handling of too large numbers
...
function old new delta
parse_with_base - 170 +170
evaluate_string 1477 1309 -168
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 170/-168) Total: 2 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-25 17:42:05 +02:00
Denys Vlasenko
019dd31150
shell/math: disable debug again
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-19 10:23:58 +02:00
Denys Vlasenko
db0e886735
shell/math: $((1?)) has one-too-small opstack, fix this
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-19 10:22:15 +02:00
Denys Vlasenko
a165098922
shell/math: fix comments about jammed-together num+num corner cases
...
function old new delta
evaluate_string 1478 1470 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-19 09:44:04 +02:00
Denys Vlasenko
79b90cbece
shell/math: add note on ERANGE
...
function old new delta
evaluate_string 1488 1478 -10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 20:15:35 +02:00
Denys Vlasenko
10cce8ae35
shell/math: explain why we use separate &end
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 19:30:22 +02:00
Denys Vlasenko
7701b526a7
shell/math: code shrink
...
function old new delta
evaluate_string 1498 1491 -7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 19:20:10 +02:00
Denys Vlasenko
8309c9159f
shell/math: eliminate redundant endofname()
...
function old new delta
evaluate_string 1486 1498 +12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 19:03:05 +02:00
Denys Vlasenko
b61fd8ec5a
shell: typo fix in tests
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 18:49:00 +02:00
Denys Vlasenko
2d06c83b87
shell/math: code shrink
...
function old new delta
evaluate_string 1489 1486 -3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 18:31:55 +02:00
Denys Vlasenko
c72c5552ed
shell/math: decrease stack usage by not allocating copies of variable names
...
We risk exhaust stack with alloca() with old code.
function old new delta
arith_apply 990 1023 +33
evaluate_string 1467 1494 +27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 60/0) Total: 60 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 18:12:14 +02:00
Denys Vlasenko
182e5a4d00
shell/math: decrease stack usage
...
function old new delta
evaluate_string 1412 1467 +55
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 18:12:04 +02:00
Denys Vlasenko
96769486e2
shell: move varcmp() to shell_common.h and use it in hush
...
function old new delta
unset_local_var - 112 +112
findvar 31 35 +4
set_vars_and_save_old 144 141 -3
helper_export_local 235 230 -5
set_local_var 425 416 -9
handle_changed_special_names 38 27 -11
builtin_unset 154 141 -13
builtin_getopts 404 391 -13
get_local_var_value 281 260 -21
get_ptr_to_local_var 71 45 -26
unset_local_var_len 139 - -139
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/8 up/down: 116/-240) Total: -124 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 21:13:13 +02:00
Denys Vlasenko
d0441222db
ash: code shrink
...
function old new delta
setvar 166 164 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 20:45:02 +02:00
Denys Vlasenko
2ca9c45953
shell/read: do not allow empty variable name
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 19:52:20 +02:00
Denys Vlasenko
822590f5e2
shell/math: eliminate some redundant stores on return code path
...
function old new delta
evaluate_string 1432 1412 -20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 19:21:28 +02:00
Denys Vlasenko
19a74a54de
shell/math: change ?: nesting code to not have 63 level nesting limitation
...
function old new delta
evaluate_string 1406 1432 +26
arith 36 29 -7
arith_apply 998 990 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 26/-15) Total: 11 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 11:03:02 +02:00
Denys Vlasenko
6221832bc1
shell/math.h: update comments, rearrange struct members for smaller code
...
function old new delta
arith_apply 1000 998 -2
evaluate_string 1414 1406 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10) Total: -10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 10:40:29 +02:00
Denys Vlasenko
d6f98f214b
shell/math: code shrink
...
function old new delta
evaluate_string 1432 1414 -18
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 00:28:49 +02:00
Denys Vlasenko
550696d492
shell/math: tweka comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-16 20:47:43 +02:00
Denys Vlasenko
e127985839
shell/math: fix ?: to not evaluate not-taken branches
...
This fixes ash-arith-arith-ternary1/2.tests
function old new delta
evaluate_string 1271 1432 +161
arith_apply 968 1000 +32
arith 22 36 +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 207/0) Total: 207 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-16 19:51:01 +02:00
Denys Vlasenko
f8263528cd
shell/math: simplify handling of unary plus
...
function old new delta
evaluate_string 1257 1271 +14
arith_apply 977 968 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-9) Total: 5 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 17:16:46 +02:00