Denys Vlasenko
459293b1c5
ash: fix arithmetic closing )) split by backslash-newline
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 17:58:58 +02:00
Denys Vlasenko
8286513838
hush: rework input char buffering to allow more than one-deep peek
...
This fixes backslash+newline continuation in
$VAR\
NAME
construct. (ash has a bug there as well).
function old new delta
file_peek2 - 74 +74
parse_dollar 746 773 +27
expand_vars_to_list 1143 1167 +24
setup_string_in_str 32 46 +14
setup_file_in_str 33 47 +14
file_get 264 278 +14
static_peek2 - 7 +7
file_peek 91 72 -19
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/1 up/down: 174/-19) Total: 155 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 16:59:06 +02:00
Denys Vlasenko
78c9c736ab
hush: fix 'eval ""' handling
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 01:44:17 +02:00
Denys Vlasenko
992e0ff7e9
hush: fix ". EMPTY_LINE" not setting $? to 0
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 01:27:09 +02:00
Denys Vlasenko
928e2a7ef4
ash: [EVAL] Make eval with empty arguments return 0
...
This is a backport of upstream commit:
[EVAL] Make eval with empty arguments return 0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-29 00:30:31 +02:00
Denys Vlasenko
eb17b6f6c9
ash: eval: Return status in eval functions
...
Backported from dash:
eval: Return status in eval functions
The exit status is currently clobbered too early for case statements
and loops. This patch fixes it by making the eval functions return
the current exit status and setting them in one place -- evaltree.
Harald van Dijk pointed out a number of bugs in the original patch.
function old new delta
evalcommand 1226 1242 +16
cmdloop 383 398 +15
evalfor 223 227 +4
evalcase 271 275 +4
localcmd 348 350 +2
evaltreenr 927 928 +1
evaltree 927 928 +1
evalsubshell 150 151 +1
evalpipe 356 357 +1
parse_command 1585 1584 -1
evalloop 177 164 -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 9/2 up/down: 45/-14) Total: 31 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-28 19:41:57 +02:00
Denys Vlasenko
aa3576a29b
hush: fix "redirects can close script fd" bug
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-22 19:54:12 +02:00
Denys Vlasenko
215b0ca6e4
hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186
...
Run this in a "sh SCRIPT":
sha256sum /dev/null
echo END
sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s.
By this time, entire script is read, and buffered in a FILE object
from fopen("SCRIPT"). But fgetc() did not consume entire input.
exit() lseeks back by -9 bytes, from <eof> to 'e' in 'echo'.
(this may be libc-specific).
This change of fd position *is shared with the parent*!
Now parent can read more, and it thinks there is another "echo END".
End result: two "echo END"s are run.
Fix this by _exit()ing instead.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 18:43:06 +02:00
Denys Vlasenko
bc9bee01f3
hush-misc/func_args1.tests: remove "UNFIXED BUG", it does not fail
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-11-04 14:50:19 +01:00
Denys Vlasenko
112889d706
hush: copy for.tests from ash testsuite
...
This test passes for hush
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-29 22:37:25 +01:00
Denys Vlasenko
450a367a11
typo fix
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-13 01:49:06 +02:00
Denys Vlasenko
b5be13ccd9
hush: fix a nommu bug where a part of function body is lost if run in a pipe
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-04 06:22:10 +02:00
Denys Vlasenko
26c423d9a8
ash,hush: add a test which fails for ash since commit 549deab
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-09-04 03:33:02 +02:00
Denys Vlasenko
9a595bb36d
hush: add recent ash tests to hush testsuite too (they all pass for hush)
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-18 10:23:16 +02:00
Denys Vlasenko
73327a048b
hush: document buggy handling of duplicate "local"
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-18 19:38:13 +02:00
Denys Vlasenko
c538d5bcc3
hush: make ${#var} unicode-aware
...
This mimics bash
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-13 09:57:44 +02:00
Denys Vlasenko
3beab83e4f
hush: fix for "while false && true; do echo BUG; break; done". closes 6170
...
function old new delta
run_list 959 941 -18
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-07 18:16:58 +02:00
Denys Vlasenko
88b532d59a
hush: source builtin should override $N only if it has args
...
function old new delta
builtin_source 174 184 +10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-17 14:11:04 +01:00
Denys Vlasenko
6e42b89b8d
hush: fix remaining known two bugs with IFS expansion. Closes 4027.
...
function old new delta
expand_vars_to_list 1054 1140 +86
parse_stream 2425 2479 +54
expand_on_ifs 258 310 +52
builtin_umask 133 132 -1
done_word 820 779 -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 192/-42) Total: 150 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-01 18:16:43 +02:00
Denys Vlasenko
4fb53fb08c
hush: partially fix wrong expansion on $IFS (bug 4027).
...
In the added testcase, before patch we failed 8 out of 9 tests,
now we fail only 2 (4th and 5th).
function old new delta
expand_on_ifs 225 258 +33
expand_vars_to_list 1038 1054 +16
o_save_ptr_helper 115 119 +4
builtin_umask 132 133 +1
o_addQstr 165 161 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 54/-4) Total: 50 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-01 14:06:20 +02:00
Denys Vlasenko
00ae989ee5
hush: fix a corner case of empty "do \n done" structure
...
The structure is:
while cmd; do
done
bash doesn't accept it at all. We were accepting it but execution
was buggy.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-31 17:35:45 +02:00
Denys Vlasenko
29f9b7268a
hush: fix misparsing of "... do eval a= ...". Closes 3721
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-14 11:27:36 +02:00
Denys Vlasenko
bcf1fa80f3
hush: add tests for interrupting read
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-09 01:05:33 +02:00
Denys Vlasenko
c162bcdcd1
hush: document a bug about aborting on sourced file error when non-interactive
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-24 05:38:51 +01:00
Denys Vlasenko
68d5cb5dac
hush: fix a case where return in sourced file has no effect
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-24 02:50:03 +01:00
Denys Vlasenko
bac0a25f72
slightly better wording in comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-21 03:47:50 +01:00
Denys Vlasenko
b12553faa8
ash: fix ash-signals/signal8 testcase failure
...
function old new delta
killcmd 109 224 +115
kill_main 882 910 +28
changepath 194 195 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 144/0) Total: 144 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-21 03:22:20 +01:00
Denys Vlasenko
8ee2adab21
echo: do not retry on write errors
...
function old new delta
echo_main 297 336 +39
stpcpy - 22 +22
run_pipe 1561 1566 +5
pseudo_exec_argv 187 192 +5
hush_exit 75 80 +5
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 4/0 up/down: 98/0) Total: 76 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-07 02:03:51 +01:00
Denys Vlasenko
7b4c0fd5f4
hush: fix improper handling of newline and hash chars in few corner cases
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-11-22 17:58:14 +01:00
Denys Vlasenko
6696eac274
hush: add support for "set -o pipefail"
...
function old new delta
checkjobs 467 517 +50
builtin_set 259 286 +27
o_opt_strings - 10 +10
hush_main 1011 1013 +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 89/0) Total: 89 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-14 02:01:50 +01:00
Denys Vlasenko
2bcba5cc53
hush: add brace expansion testcase
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-03 17:07:57 +02:00
Denys Vlasenko
bed7c81ea2
shell/math: deconvolute and explain ?: handling. Give better error message
...
function old new delta
arith_apply 1271 1283 +12
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 11:50:46 +02:00
Denys Vlasenko
063847d6bd
shell/math: return string error indicator, not integer
...
function old new delta
expand_and_evaluate_arith 87 106 +19
expand_one_var 1563 1570 +7
arith 12 18 +6
evaluate_string 678 680 +2
arith_apply 1269 1271 +2
builtin_umask 133 132 -1
ash_arith 118 75 -43
expand_vars_to_list 1094 1038 -56
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/3 up/down: 36/-100) Total: -64 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-15 13:33:02 +02:00
Denys Vlasenko
a110c90de2
hush: fix EXIT trap display inside exit trap handler
...
function old new delta
hush_exit 84 78 -6
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:38:04 +02:00
Denys Vlasenko
acd5bc8f64
hush: fix handling of \" in quoted/unquoted cmd
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:05:39 +02:00
Denys Vlasenko
4f870496e7
hush: do fewer strdups in % and hash expansions
...
function old new delta
builtin_umask 133 132 -1
expand_one_var 1552 1543 -9
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 11:06:01 +02:00
Denys Vlasenko
cc461736d6
hush: fixes to testsuite
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:19:22 +02:00
Denys Vlasenko
ebee410fe2
hush: fix var_bash5.tests failure
...
function old new delta
expand_one_var 1513 1552 +39
expand_pseudo_dquoted 118 135 +17
expand_string_to_string 110 126 +16
setup_heredoc 298 308 +10
expand_and_evaluate_arith 69 79 +10
parse_stream_dquoted 233 241 +8
setup_redirects 220 225 +5
run_list 956 961 +5
expand_assignments 76 81 +5
run_pipe 1587 1590 +3
parse_stream 2371 2374 +3
builtin_umask 132 133 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 12/0 up/down: 122/0) Total: 122 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:17:53 +02:00
Denys Vlasenko
101a4e3e21
hush: make parse_dollar flag quited status regardless of glob escaping status
...
function old new delta
parse_stream_dquoted 228 233 +5
parse_stream 2369 2371 +2
parse_dollar 730 717 -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 7/-13) Total: -6 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 14:04:57 +02:00
Denys Vlasenko
c3adfacd22
hush: fix another corner case with backslashes in heredocs
...
function old new delta
parse_stream 2395 2432 +37
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:46:03 +02:00
Denys Vlasenko
77b32ccbf2
hush: fix backslash and terminator handling in <<[-]["]heredoc["]
...
function old new delta
parse_stream 2339 2395 +56
expand_pseudo_dquoted 104 118 +14
parse_stream_dquoted 296 300 +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 74/0) Total: 74 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:27:32 +02:00
Denys Vlasenko
c49d2d9793
hush: fix globbing+backslashes in unquoted $var expansion
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:26:37 +02:00
Denys Vlasenko
36f774a0cd
hush: add support for ${var/pattern/repl}, conditional on bash compat
...
function old new delta
expand_vars_to_list 2386 2833 +447
expand_string_to_string 69 110 +41
parse_dollar 681 721 +40
hush_main 963 945 -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 528/-18) Total: 510 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:47:58 +02:00
Denys Vlasenko
e298ce69ba
hush: fix handling of backslashes in variable assignment
...
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-04 19:52:44 +02:00
Denys Vlasenko
ba2dcccd79
*: trailing empty lines removed
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-26 01:49:12 +02:00
Alexander Shishkin
ccb9771861
ash: fix $! value when traps are set
...
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-25 13:07:39 +02:00
Denys Vlasenko
29082231d0
hush: fix multimple dependent variable expansion cases
...
function old new delta
get_local_var_value 100 171 +71
expand_assignments 46 76 +30
reset_traps_to_defaults 229 238 +9
maybe_set_to_sigexit 47 50 +3
init_sigmasks 211 214 +3
builtin_trap 462 465 +3
expand_vars_to_list 2412 2408 -4
run_pipe 1568 1533 -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/2 up/down: 119/-39) Total: 80 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 13:52:32 +02:00
Denys Vlasenko
e85248afa2
hush: fix segfault in ${?:N:M}
...
function old new delta
expand_vars_to_list 2374 2409 +35
builtin_umask 132 133 +1
builtin_exit 47 48 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 37/0) Total: 37 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 06:20:26 +02:00
Denys Vlasenko
8a33679694
hush: fix "hush -c 'echo $#'" showing -1
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 06:05:02 +02:00
Denys Vlasenko
1e811b1231
hush: support ${var:EXPR:EXPR}!
...
function old new delta
handle_dollar 574 681 +107
expand_and_evaluate_arith - 77 +77
expand_vars_to_list 2302 2374 +72
add_till_closing_bracket 359 368 +9
builtin_exit 48 47 -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 265/-1) Total: 264 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-22 03:12:29 +02:00