From 53d45c934f54b7931cc736eba42903cb1f6d4632 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 25 Jul 2021 21:54:14 +0200 Subject: ash: speed up ${v//pattern/repl} function old new delta subevalvar 1447 1457 +10 Signed-off-by: Denys Vlasenko --- shell/ash.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 092f3bcc7..b5947147a 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7284,7 +7284,7 @@ subevalvar(char *start, char *str, int strloc, while (idx <= end) { try_to_match: if (no_meta_len == 0) { - /* pattern has meta chars, have to glob; or ENABLE_ASH_OPTIMIZE_FOR_SIZE */ + /* pattern has meta chars, have to glob; or ENABLE_ASH_OPTIMIZE_FOR_SIZE */ loc = scanright(idx, rmesc, rmescend, str, quotes, /*match_at_start:*/ 1); } else { /* Testcase for very slow replace (performs about 22k replaces): @@ -7292,16 +7292,19 @@ subevalvar(char *start, char *str, int strloc, * x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;echo ${#x} * echo "${x//:/|}" */ - size_t n; if (strncmp(rmesc, str, no_meta_len) != 0) goto no_match; - n = no_meta_len; loc = idx; - do { - if (quotes && (unsigned char)*loc == CTLESC) + if (!quotes) { + loc += no_meta_len; + } else { + size_t n = no_meta_len; + do { + if ((unsigned char)*loc == CTLESC) + loc++; loc++; - loc++; - } while (--n != 0); + } while (--n != 0); + } } //bb_error_msg("scanright('%s'):'%s'", str, loc); if (!loc) { -- cgit v1.2.3-55-g6feb From 05c5d745f7b14e265144489b7809a3d6dbbadec6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 25 Jul 2021 22:03:16 +0200 Subject: ahell: update testsuite Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-vars/var6.right | 2 ++ shell/ash_test/ash-vars/var6.tests | 5 +++++ shell/ash_test/ash-vars/var_nested1.right | 3 +++ shell/ash_test/ash-vars/var_nested1.tests | 16 ++++++++++++++++ shell/ash_test/ash-vars/var_nested2.right | 1 + shell/ash_test/ash-vars/var_nested2.tests | 2 ++ shell/hush_test/hush-vars/var6.tests | 7 ++++--- 7 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 shell/ash_test/ash-vars/var6.right create mode 100755 shell/ash_test/ash-vars/var6.tests create mode 100644 shell/ash_test/ash-vars/var_nested1.right create mode 100755 shell/ash_test/ash-vars/var_nested1.tests create mode 100644 shell/ash_test/ash-vars/var_nested2.right create mode 100755 shell/ash_test/ash-vars/var_nested2.tests diff --git a/shell/ash_test/ash-vars/var6.right b/shell/ash_test/ash-vars/var6.right new file mode 100644 index 000000000..b37417fa1 --- /dev/null +++ b/shell/ash_test/ash-vars/var6.right @@ -0,0 +1,2 @@ +SHELL: line 1: syntax error: bad substitution +SHELL: line 1: syntax error: bad substitution diff --git a/shell/ash_test/ash-vars/var6.tests b/shell/ash_test/ash-vars/var6.tests new file mode 100755 index 000000000..626e60ee1 --- /dev/null +++ b/shell/ash_test/ash-vars/var6.tests @@ -0,0 +1,5 @@ +# reject invalid vars +# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages) +"$THIS_SH" -c 'echo ${1q}' SHELL +"$THIS_SH" -c 'echo ${&}' SHELL +#"$THIS_SH" -c 'echo ${$}' SHELL -- this is valid as it's the same as $$ diff --git a/shell/ash_test/ash-vars/var_nested1.right b/shell/ash_test/ash-vars/var_nested1.right new file mode 100644 index 000000000..f4bc5f4b6 --- /dev/null +++ b/shell/ash_test/ash-vars/var_nested1.right @@ -0,0 +1,3 @@ +Expected:AB Actual:AB +Expected:Ab Actual:Ab +Expected:ab Actual:ab diff --git a/shell/ash_test/ash-vars/var_nested1.tests b/shell/ash_test/ash-vars/var_nested1.tests new file mode 100755 index 000000000..59e4a14fa --- /dev/null +++ b/shell/ash_test/ash-vars/var_nested1.tests @@ -0,0 +1,16 @@ +f() { a=A; b=B; } + +a=a +b=b +f +echo Expected:AB Actual:$a$b + +a=a +b=b +b= f +echo Expected:Ab Actual:$a$b + +a=a +b=b +a= b= f +echo Expected:ab Actual:$a$b diff --git a/shell/ash_test/ash-vars/var_nested2.right b/shell/ash_test/ash-vars/var_nested2.right new file mode 100644 index 000000000..c930d971c --- /dev/null +++ b/shell/ash_test/ash-vars/var_nested2.right @@ -0,0 +1 @@ +aB diff --git a/shell/ash_test/ash-vars/var_nested2.tests b/shell/ash_test/ash-vars/var_nested2.tests new file mode 100755 index 000000000..e8865861e --- /dev/null +++ b/shell/ash_test/ash-vars/var_nested2.tests @@ -0,0 +1,2 @@ +# the bug was easier to trigger in one-liner form +a=a; b=b; f() { a=A; b=B; }; a= f; echo $a$b diff --git a/shell/hush_test/hush-vars/var6.tests b/shell/hush_test/hush-vars/var6.tests index aea36d62d..626e60ee1 100755 --- a/shell/hush_test/hush-vars/var6.tests +++ b/shell/hush_test/hush-vars/var6.tests @@ -1,4 +1,5 @@ # reject invalid vars -"$THIS_SH" -c 'echo ${1q}' -"$THIS_SH" -c 'echo ${&}' -#"$THIS_SH" -c 'echo ${$}' -- this is valid as it's the same as $$ +# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages) +"$THIS_SH" -c 'echo ${1q}' SHELL +"$THIS_SH" -c 'echo ${&}' SHELL +#"$THIS_SH" -c 'echo ${$}' SHELL -- this is valid as it's the same as $$ -- cgit v1.2.3-55-g6feb From b278d82c61ab5125b5c7e350b264c1f3d52d682b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 26 Jul 2021 15:29:13 +0200 Subject: hush: implement $'str' bashism function old new delta parse_dollar_squote - 441 +441 encode_then_expand_vararg 359 380 +21 parse_stream 2252 2271 +19 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 481/0) Total: 481 bytes Signed-off-by: Denys Vlasenko --- shell/hush.c | 103 ++++++++++++++++++++- .../hush-quoting/dollar_squote_bash1.right | 10 ++ .../hush-quoting/dollar_squote_bash1.tests | 8 ++ .../hush-quoting/dollar_squote_bash2.right | 6 ++ .../hush-quoting/dollar_squote_bash2.tests | 10 ++ shell/hush_test/hush-vars/var_bash7.right | 1 + shell/hush_test/hush-vars/var_bash7.tests | 1 + 7 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 shell/hush_test/hush-quoting/dollar_squote_bash1.right create mode 100755 shell/hush_test/hush-quoting/dollar_squote_bash1.tests create mode 100644 shell/hush_test/hush-quoting/dollar_squote_bash2.right create mode 100755 shell/hush_test/hush-quoting/dollar_squote_bash2.tests create mode 100644 shell/hush_test/hush-vars/var_bash7.right create mode 100755 shell/hush_test/hush-vars/var_bash7.tests diff --git a/shell/hush.c b/shell/hush.c index 1aa0a400d..af6a9a73e 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -384,6 +384,7 @@ #define BASH_PATTERN_SUBST ENABLE_HUSH_BASH_COMPAT #define BASH_SUBSTR ENABLE_HUSH_BASH_COMPAT #define BASH_SOURCE ENABLE_HUSH_BASH_COMPAT +#define BASH_DOLLAR_SQUOTE ENABLE_HUSH_BASH_COMPAT #define BASH_HOSTNAME_VAR ENABLE_HUSH_BASH_COMPAT #define BASH_EPOCH_VARS ENABLE_HUSH_BASH_COMPAT #define BASH_TEST2 (ENABLE_HUSH_BASH_COMPAT && ENABLE_HUSH_TEST) @@ -4919,6 +4920,100 @@ static int add_till_closing_bracket(o_string *dest, struct in_str *input, unsign } #endif /* ENABLE_HUSH_TICK || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_DOLLAR_OPS */ +#if BASH_DOLLAR_SQUOTE +/* Return code: 1 for "found and parsed", 0 for "seen something else" */ +#if BB_MMU +#define parse_dollar_squote(as_string, dest, input) \ + parse_dollar_squote(dest, input) +#define as_string NULL +#endif +static int parse_dollar_squote(o_string *as_string, o_string *dest, struct in_str *input) +{ + int start; + int ch = i_peek_and_eat_bkslash_nl(input); /* first character after the $ */ + debug_printf_parse("parse_dollar_squote entered: ch='%c'\n", ch); + if (ch != '\'') + return 0; + + dest->has_quoted_part = 1; + start = dest->length; + + ch = i_getch(input); /* eat ' */ + nommu_addchr(as_string, ch); + while (1) { + ch = i_getch(input); + nommu_addchr(as_string, ch); + if (ch == EOF) { + syntax_error_unterm_ch('\''); + return 0; + } + if (ch == '\'') + break; + if (ch == SPECIAL_VAR_SYMBOL) { + /* Convert raw ^C to corresponding special variable reference */ + o_addchr(dest, SPECIAL_VAR_SYMBOL); + o_addchr(dest, SPECIAL_VAR_QUOTED_SVS); + /* will addchr() another SPECIAL_VAR_SYMBOL (see after the if() block) */ + } else if (ch == '\\') { + static const char C_escapes[] ALIGN1 = "nrbtfav""x\\01234567"; + + ch = i_getch(input); + nommu_addchr(as_string, ch); + if (strchr(C_escapes, ch)) { + char buf[4]; + char *p = buf; + int cnt = 2; + + buf[0] = ch; + if ((unsigned char)(ch - '0') <= 7) { /* \ooo */ + do { + ch = i_peek(input); + if ((unsigned char)(ch - '0') > 7) + break; + *++p = ch = i_getch(input); + nommu_addchr(as_string, ch); + } while (--cnt != 0); + } else if (ch == 'x') { /* \xHH */ + do { + ch = i_peek(input); + if (!isxdigit(ch)) + break; + *++p = ch = i_getch(input); + nommu_addchr(as_string, ch); + } while (--cnt != 0); + if (cnt == 2) { /* \x but next char is "bad" */ + ch = 'x'; + goto unrecognized; + } + } /* else simple seq like \\ or \t */ + *++p = '\0'; + p = buf; + ch = bb_process_escape_sequence((void*)&p); + //bb_error_msg("buf:'%s' ch:%x", buf, ch); + if (ch == '\0') + continue; /* bash compat: $'...\0...' emits nothing */ + } else { /* unrecognized "\z": encode both chars unless ' or " */ + if (ch != '\'' && ch != '"') { + unrecognized: + o_addqchr(dest, '\\'); + } + } + } /* if (\...) */ + o_addqchr(dest, ch); + } + + if (dest->length == start) { + /* $'', $'\0', $'\000\x00' and the like */ + o_addchr(dest, SPECIAL_VAR_SYMBOL); + o_addchr(dest, SPECIAL_VAR_SYMBOL); + } + + return 1; +} +#else +# #define parse_dollar_squote(as_string, dest, input) 0 +#endif /* BASH_DOLLAR_SQUOTE */ + /* Return code: 0 for OK, 1 for syntax error */ #if BB_MMU #define parse_dollar(as_string, dest, input, quote_mask) \ @@ -4931,7 +5026,7 @@ static int parse_dollar(o_string *as_string, { int ch = i_peek_and_eat_bkslash_nl(input); /* first character after the $ */ - debug_printf_parse("parse_dollar entered: ch='%c'\n", ch); + debug_printf_parse("parse_dollar entered: ch='%c' quote_mask:0x%x\n", ch, quote_mask); if (isalpha(ch)) { make_var: ch = i_getch(input); @@ -5247,6 +5342,8 @@ static int encode_string(o_string *as_string, goto again; } if (ch == '$') { + //if (parse_dollar_squote(as_string, dest, input)) + // goto again; if (!parse_dollar(as_string, dest, input, /*quote_mask:*/ 0x80)) { debug_printf_parse("encode_string return 0: " "parse_dollar returned 0 (error)\n"); @@ -5723,6 +5820,8 @@ static struct pipe *parse_stream(char **pstring, o_addchr(&ctx.word, ch); continue; /* get next char */ case '$': + if (parse_dollar_squote(&ctx.as_string, &ctx.word, input)) + continue; /* get next char */ if (!parse_dollar(&ctx.as_string, &ctx.word, input, /*quote_mask:*/ 0)) { debug_printf_parse("parse_stream parse error: " "parse_dollar returned 0 (error)\n"); @@ -6166,6 +6265,8 @@ static char *encode_then_expand_vararg(const char *str, int handle_squotes, int continue; } if (ch == '$') { + if (parse_dollar_squote(NULL, &dest, &input)) + continue; if (!parse_dollar(NULL, &dest, &input, /*quote_mask:*/ 0x80)) { debug_printf_parse("%s: error: parse_dollar returned 0 (error)\n", __func__); goto ret; diff --git a/shell/hush_test/hush-quoting/dollar_squote_bash1.right b/shell/hush_test/hush-quoting/dollar_squote_bash1.right new file mode 100644 index 000000000..9f4e25efa --- /dev/null +++ b/shell/hush_test/hush-quoting/dollar_squote_bash1.right @@ -0,0 +1,10 @@ +a b +$'a\tb' +a +b c +def +a'b c"d e\f +a3b c3b e33f +a\80b c08b +a3b c30b +x y diff --git a/shell/hush_test/hush-quoting/dollar_squote_bash1.tests b/shell/hush_test/hush-quoting/dollar_squote_bash1.tests new file mode 100755 index 000000000..6fc411b93 --- /dev/null +++ b/shell/hush_test/hush-quoting/dollar_squote_bash1.tests @@ -0,0 +1,8 @@ +echo $'a\tb' +echo "$'a\tb'" +echo $'a\nb' $'c\nd''ef' +echo $'a\'b' $'c\"d' $'e\\f' +echo $'a\63b' $'c\063b' $'e\0633f' +echo $'a\80b' $'c\608b' +echo $'a\x33b' $'c\x330b' +echo $'x\x9y' diff --git a/shell/hush_test/hush-quoting/dollar_squote_bash2.right b/shell/hush_test/hush-quoting/dollar_squote_bash2.right new file mode 100644 index 000000000..f7a1731dd --- /dev/null +++ b/shell/hush_test/hush-quoting/dollar_squote_bash2.right @@ -0,0 +1,6 @@ +strstrstrstrstrstrstrstrstrstrstrstrstrstrstrstrstr +strstrstrstrstrstrstrstrstrstrstrstrstrstrstrstrstr +80:\ +81:\ +82:\ +Done:0 diff --git a/shell/hush_test/hush-quoting/dollar_squote_bash2.tests b/shell/hush_test/hush-quoting/dollar_squote_bash2.tests new file mode 100755 index 000000000..449772813 --- /dev/null +++ b/shell/hush_test/hush-quoting/dollar_squote_bash2.tests @@ -0,0 +1,10 @@ +# Embedded NULs +echo $'str\x00'strstrstrstrstrstrstrstrstrstrstrstrstrstrstrstr +echo $'str\000'strstrstrstrstrstrstrstrstrstrstrstrstrstrstrstr + +# The chars after '\' are hex 0x80,81,82... +echo 80:$'\' +echo 81:$'\' +echo 82:$'\' + +echo Done:$? diff --git a/shell/hush_test/hush-vars/var_bash7.right b/shell/hush_test/hush-vars/var_bash7.right new file mode 100644 index 000000000..223b7836f --- /dev/null +++ b/shell/hush_test/hush-vars/var_bash7.right @@ -0,0 +1 @@ +B diff --git a/shell/hush_test/hush-vars/var_bash7.tests b/shell/hush_test/hush-vars/var_bash7.tests new file mode 100755 index 000000000..c4ce03f7f --- /dev/null +++ b/shell/hush_test/hush-vars/var_bash7.tests @@ -0,0 +1 @@ +x=AB; echo "${x#$'\x41'}" -- cgit v1.2.3-55-g6feb From 8dd676c6c3b862846a4a215f5f3a8822fcf8c569 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 27 Jul 2021 04:09:45 +0200 Subject: hush: add missed "undef" Signed-off-by: Denys Vlasenko --- shell/hush.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index af6a9a73e..6b910569f 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -4922,11 +4922,11 @@ static int add_till_closing_bracket(o_string *dest, struct in_str *input, unsign #if BASH_DOLLAR_SQUOTE /* Return code: 1 for "found and parsed", 0 for "seen something else" */ -#if BB_MMU +# if BB_MMU #define parse_dollar_squote(as_string, dest, input) \ parse_dollar_squote(dest, input) #define as_string NULL -#endif +# endif static int parse_dollar_squote(o_string *as_string, o_string *dest, struct in_str *input) { int start; @@ -5009,6 +5009,7 @@ static int parse_dollar_squote(o_string *as_string, o_string *dest, struct in_st } return 1; +# undef as_string } #else # #define parse_dollar_squote(as_string, dest, input) 0 @@ -5949,7 +5950,6 @@ static struct pipe *parse_stream(char **pstring, if (ctx.ctx_res_w == RES_MATCH) goto case_semi; #endif - case '}': /* proper use of this character is caught by end_trigger: * if we see {, we call parse_group(..., end_trigger='}') -- cgit v1.2.3-55-g6feb From c450437a4e631378cd6a2dc06a5923ce811a950d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 27 Jul 2021 04:20:32 +0200 Subject: shell: update psubst testcases Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-psubst/falsetick.right | 24 ++++++++++++++++++++++++ shell/ash_test/ash-psubst/falsetick.tests | 19 +++++++++++++++++++ shell/ash_test/ash-psubst/falsetick2.right | 1 + shell/ash_test/ash-psubst/falsetick2.tests | 3 +++ shell/hush_test/hush-psubst/falsetick.right | 3 --- shell/hush_test/hush-psubst/falsetick.tests | 3 --- shell/hush_test/hush-psubst/falsetick3.right | 3 +++ shell/hush_test/hush-psubst/falsetick3.tests | 3 +++ 8 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 shell/ash_test/ash-psubst/falsetick.right create mode 100755 shell/ash_test/ash-psubst/falsetick.tests create mode 100644 shell/ash_test/ash-psubst/falsetick2.right create mode 100755 shell/ash_test/ash-psubst/falsetick2.tests create mode 100644 shell/hush_test/hush-psubst/falsetick3.right create mode 100755 shell/hush_test/hush-psubst/falsetick3.tests diff --git a/shell/ash_test/ash-psubst/falsetick.right b/shell/ash_test/ash-psubst/falsetick.right new file mode 100644 index 000000000..0335254a8 --- /dev/null +++ b/shell/ash_test/ash-psubst/falsetick.right @@ -0,0 +1,24 @@ +0 +0 +0 +0 +2 +2 +2 +2 +./falsetick.tests: line 12: can't create /does/not/exist: nonexistent directory +1 +./falsetick.tests: line 13: can't create /does/not/exist: nonexistent directory +1 +./falsetick.tests: line 14: can't create /does/not/exist: nonexistent directory +1 +./falsetick.tests: line 15: can't create /does/not/exist: nonexistent directory +1 +./falsetick.tests: line 16: can't create /does/not/exist: nonexistent directory +1 +./falsetick.tests: line 17: can't create /does/not/exist: nonexistent directory +1 +./falsetick.tests: line 18: can't create /does/not/exist: nonexistent directory +1 +./falsetick.tests: line 19: can't create /does/not/exist: nonexistent directory +1 diff --git a/shell/ash_test/ash-psubst/falsetick.tests b/shell/ash_test/ash-psubst/falsetick.tests new file mode 100755 index 000000000..d2b93695e --- /dev/null +++ b/shell/ash_test/ash-psubst/falsetick.tests @@ -0,0 +1,19 @@ +# Exitcode 0 (`` has no exitcode, but assignment has): +true; a=``; echo $? +false; a=``; echo $? +true; a=$(); echo $? +false; a=$(); echo $? +# Exitcode 2 (`cmd` expansion sets exitcode after assignment set it to 0): +true; a=`exit 2`; echo $? +false; a=`exit 2`; echo $? +true; a=$(exit 2); echo $? +false; a=$(exit 2); echo $? +# Exitcode 1 (redirect sets exitcode to 1 on error after them): +true; a=`` >/does/not/exist; echo $? +false; a=`` >/does/not/exist; echo $? +true; a=$() >/does/not/exist; echo $? +false; a=$() >/does/not/exist; echo $? +true; a=`exit 2` >/does/not/exist; echo $? +false; a=`exit 2` >/does/not/exist; echo $? +true; a=$(exit 2) >/does/not/exist; echo $? +false; a=$(exit 2) >/does/not/exist; echo $? diff --git a/shell/ash_test/ash-psubst/falsetick2.right b/shell/ash_test/ash-psubst/falsetick2.right new file mode 100644 index 000000000..670f560f1 --- /dev/null +++ b/shell/ash_test/ash-psubst/falsetick2.right @@ -0,0 +1 @@ +Two:2 v:[] diff --git a/shell/ash_test/ash-psubst/falsetick2.tests b/shell/ash_test/ash-psubst/falsetick2.tests new file mode 100755 index 000000000..cfbd1a5de --- /dev/null +++ b/shell/ash_test/ash-psubst/falsetick2.tests @@ -0,0 +1,3 @@ +v=v +v=`exit 2` `false` +echo Two:$? v:"[$v]" diff --git a/shell/hush_test/hush-psubst/falsetick.right b/shell/hush_test/hush-psubst/falsetick.right index 0b98fb778..d2d1a2880 100644 --- a/shell/hush_test/hush-psubst/falsetick.right +++ b/shell/hush_test/hush-psubst/falsetick.right @@ -22,6 +22,3 @@ hush: can't open '/does/not/exist': No such file or directory 1 hush: can't open '/does/not/exist': No such file or directory 1 -hush: can't open '/does/not/exist': No such file or directory -1 -Done: a=b diff --git a/shell/hush_test/hush-psubst/falsetick.tests b/shell/hush_test/hush-psubst/falsetick.tests index 44d2eae8b..d2b93695e 100755 --- a/shell/hush_test/hush-psubst/falsetick.tests +++ b/shell/hush_test/hush-psubst/falsetick.tests @@ -17,6 +17,3 @@ true; a=`exit 2` >/does/not/exist; echo $? false; a=`exit 2` >/does/not/exist; echo $? true; a=$(exit 2) >/does/not/exist; echo $? false; a=$(exit 2) >/does/not/exist; echo $? -# ...and assignment still happens despite redirect error: -true; a=$(echo b) >/does/not/exist; echo $? -echo "Done: a=$a" diff --git a/shell/hush_test/hush-psubst/falsetick3.right b/shell/hush_test/hush-psubst/falsetick3.right new file mode 100644 index 000000000..327849a31 --- /dev/null +++ b/shell/hush_test/hush-psubst/falsetick3.right @@ -0,0 +1,3 @@ +hush: can't open '/does/not/exist': No such file or directory +1 +Done: a=b diff --git a/shell/hush_test/hush-psubst/falsetick3.tests b/shell/hush_test/hush-psubst/falsetick3.tests new file mode 100755 index 000000000..cd185335e --- /dev/null +++ b/shell/hush_test/hush-psubst/falsetick3.tests @@ -0,0 +1,3 @@ +# assignment still happens despite redirect error +true; a=$(echo b) >/does/not/exist; echo $? +echo "Done: a=$a" -- cgit v1.2.3-55-g6feb From 49cc3cac30c504abdbd2c075928f5711da4066e8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 27 Jul 2021 17:53:55 +0200 Subject: hush: optimize ${var/pattern/repl} for trivial patterns function old new delta expand_one_var 2353 2507 +154 Signed-off-by: Denys Vlasenko --- shell/hush.c | 13 +++++++++++++ shell/match.c | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 6b910569f..179155f66 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -6466,6 +6466,19 @@ static arith_t expand_and_evaluate_arith(const char *arg, const char **errmsg_p) /* ${var/[/]pattern[/repl]} helpers */ static char *strstr_pattern(char *val, const char *pattern, int *size) { + if (!strpbrk(pattern, "*?[\\")) { + /* Optimization for trivial patterns. + * Testcase for very slow replace (performs about 22k replaces): + * x=:::::::::::::::::::::: + * x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;echo ${#x} + * echo "${x//:/|}" + */ + char *found = strstr(val, pattern); + if (found) + *size = strlen(pattern); + return found; + } + while (1) { char *end = scan_and_match(val, pattern, SCAN_MOVE_FROM_RIGHT + SCAN_MATCH_LEFT_HALF); debug_printf_varexp("val:'%s' pattern:'%s' end:'%s'\n", val, pattern, end); diff --git a/shell/match.c b/shell/match.c index ee8abb2db..90f77546d 100644 --- a/shell/match.c +++ b/shell/match.c @@ -64,11 +64,10 @@ char* FAST_FUNC scan_and_match(char *string, const char *pattern, unsigned flags } while (loc != end) { - char c; int r; - c = *loc; if (flags & SCAN_MATCH_LEFT_HALF) { + char c = *loc; *loc = '\0'; r = fnmatch(pattern, string, 0); //bb_error_msg("fnmatch('%s','%s',0):%d", pattern, string, r); -- cgit v1.2.3-55-g6feb From 37460f5daff9b9ed751ce37b912cc61de94adf09 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 27 Jul 2021 18:13:11 +0200 Subject: hush: tweak ${var/pattern/repl} optimization function old new delta expand_one_var 2507 2502 -5 Signed-off-by: Denys Vlasenko --- shell/hush.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 179155f66..c970d9097 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -6466,17 +6466,16 @@ static arith_t expand_and_evaluate_arith(const char *arg, const char **errmsg_p) /* ${var/[/]pattern[/repl]} helpers */ static char *strstr_pattern(char *val, const char *pattern, int *size) { - if (!strpbrk(pattern, "*?[\\")) { + int sz = strcspn(pattern, "*?[\\"); + if (pattern[sz] == '\0') { /* Optimization for trivial patterns. * Testcase for very slow replace (performs about 22k replaces): * x=:::::::::::::::::::::: * x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;x=$x$x;echo ${#x} * echo "${x//:/|}" */ - char *found = strstr(val, pattern); - if (found) - *size = strlen(pattern); - return found; + *size = sz; + return strstr(val, pattern); } while (1) { -- cgit v1.2.3-55-g6feb From 3d40dfabe1049ecfbe05570b2287cfc5dbd33456 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Aug 2021 19:58:13 +0200 Subject: tar: simplify addition of --exclude=GLOB to the expansion of -X EXCLFILE function old new delta tar_main 1115 1105 -10 Signed-off-by: Denys Vlasenko --- archival/tar.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/archival/tar.c b/archival/tar.c index 4a540b77a..879f6bf6f 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -1132,14 +1132,15 @@ int tar_main(int argc UNUSED_PARAM, char **argv) tar_handle->ah_flags &= ~ARCHIVE_RESTORE_DATE; #if ENABLE_FEATURE_TAR_FROM + /* Convert each -X EXCLFILE to list of to-be-rejected glob patterns */ tar_handle->reject = append_file_list_to_list(tar_handle->reject); # if ENABLE_FEATURE_TAR_LONG_OPTIONS - /* Append excludes to reject */ - while (excludes) { - llist_t *next = excludes->link; - excludes->link = tar_handle->reject; - tar_handle->reject = excludes; - excludes = next; + /* Append --exclude=GLOBPATTERNs to reject */ + if (excludes) { + llist_t **p2next = &tar_handle->reject; + while (*p2next) + p2next = &((*p2next)->link); + *p2next = excludes; } # endif tar_handle->accept = append_file_list_to_list(tar_handle->accept); -- cgit v1.2.3-55-g6feb From 8ae6a4344d5d0f46e542d835ce4d218ff902c783 Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Sun, 27 Jun 2021 15:11:57 +0100 Subject: tar: exclude files before updating hardlink info list When excluding one file, and including another file that is a hardlink of the excluded file, it should be stored as an ordinary file. function old new delta writeFileToTarball 489 493 +4 Signed-off-by: Harald van Dijk Signed-off-by: Denys Vlasenko --- archival/tar.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/archival/tar.c b/archival/tar.c index 879f6bf6f..94fb61a29 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -507,6 +507,9 @@ static int FAST_FUNC writeFileToTarball(struct recursive_state *state, if (header_name[0] == '\0') return TRUE; + if (exclude_file(tbInfo->excludeList, header_name)) + return SKIP; /* "do not recurse on this directory", no error message printed */ + /* It is against the rules to archive a socket */ if (S_ISSOCK(statbuf->st_mode)) { bb_error_msg("%s: socket ignored", fileName); @@ -540,9 +543,6 @@ static int FAST_FUNC writeFileToTarball(struct recursive_state *state, return TRUE; } - if (exclude_file(tbInfo->excludeList, header_name)) - return SKIP; - # if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS if (strlen(header_name) >= NAME_SIZE) { bb_simple_error_msg("names longer than "NAME_SIZE_STR" chars not supported"); @@ -555,13 +555,13 @@ static int FAST_FUNC writeFileToTarball(struct recursive_state *state, /* open the file we want to archive, and make sure all is well */ inputFileFd = open_or_warn(fileName, O_RDONLY); if (inputFileFd < 0) { - return FALSE; + return FALSE; /* make recursive_action() return FALSE */ } } /* Add an entry to the tarball */ if (writeTarHeader(tbInfo, header_name, fileName, statbuf) == FALSE) { - return FALSE; + return FALSE; /* make recursive_action() return FALSE */ } /* If it was a regular file, write out the body */ -- cgit v1.2.3-55-g6feb From 98cb561b5fd61fe37126fce7d557d5280c762b59 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 10 Aug 2021 09:13:02 +0100 Subject: cp: fix build failure with long options disabled When long options were disabled cp failed to compile with: coreutils/cp.c:130:9: error: empty enum is invalid 130 | }; | ^ Rearrange the conditional compilation to suit. Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- coreutils/cp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/coreutils/cp.c b/coreutils/cp.c index 50ca1ccea..ee40af50b 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -121,14 +121,12 @@ int cp_main(int argc, char **argv) int d_flags; int flags; int status; - enum { #if ENABLE_FEATURE_CP_LONG_OPTIONS + enum { /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTBITS */ OPT_parents = 1 << (FILEUTILS_CP_OPTBITS+1), OPT_reflink = 1 << (FILEUTILS_CP_OPTBITS+2), -#endif }; -#if ENABLE_FEATURE_CP_LONG_OPTIONS # if ENABLE_FEATURE_CP_REFLINK char *reflink = NULL; # endif -- cgit v1.2.3-55-g6feb From 2a1ce6b20e787525fa9adae9e68fa08e93374863 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Aug 2021 20:06:52 +0200 Subject: traceroute: fix compile error due to FreeBSD compat Signed-off-by: Denys Vlasenko --- networking/traceroute.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/networking/traceroute.c b/networking/traceroute.c index 057f8591a..4bbe1ab8e 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -713,11 +713,16 @@ packet4_ok(int read_len, int seq) up = (struct udphdr *)((char *)hip + hlen); if (hlen + 12 <= read_len && hip->ip_p == IPPROTO_UDP -// Off: since we do not form the entire IP packet, +#if !defined(__FreeBSD__) +// Disabled source check: since we do not form the entire IP packet, // but defer it to kernel, we can't set source port, // and thus can't check it here in the reply + /* && up->source == ident */ + && up->dest == htons(port + seq) +#else /* && up->uh_sport == ident */ && up->uh_dport == htons(port + seq) +#endif ) { return (type == ICMP_TIMXCEED ? -1 : code + 1); } -- cgit v1.2.3-55-g6feb From 21afddefd2587daeb86317c134221e5b8c897445 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Aug 2021 20:08:53 +0200 Subject: hush: fix "error: invalid preprocessing directive ##" Signed-off-by: Denys Vlasenko --- shell/hush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/hush.c b/shell/hush.c index c970d9097..27092c12f 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -5012,7 +5012,7 @@ static int parse_dollar_squote(o_string *as_string, o_string *dest, struct in_st # undef as_string } #else -# #define parse_dollar_squote(as_string, dest, input) 0 +# define parse_dollar_squote(as_string, dest, input) 0 #endif /* BASH_DOLLAR_SQUOTE */ /* Return code: 0 for OK, 1 for syntax error */ -- cgit v1.2.3-55-g6feb From eaa8ee40aa049040e9f9bb1d967754102742c227 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Aug 2021 20:15:42 +0200 Subject: cut: fix testsuite Signed-off-by: Denys Vlasenko --- testsuite/cut.tests | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testsuite/cut.tests b/testsuite/cut.tests index d705b91c3..2458c019c 100755 --- a/testsuite/cut.tests +++ b/testsuite/cut.tests @@ -66,6 +66,7 @@ testing "cut with -d -f(a) -s" "cut -da -f3 -s input" "n\nsium:Jim\n\ncion:Ed\n" testing "cut with -d -f(a) -s -n" "cut -da -f3 -s -n input" "n\nsium:Jim\n\ncion:Ed\n" "$input" "" # substitute for awk +optional FEATURE_CUT_REGEX testing "cut -DF" "cut -DF 2,7,5" \ "said and your\nare\nis demand. supply\nforecast :\nyou you better,\n\nEm: Took hate\n" "" \ "Bother, said Pooh. It's your husband, and he has a gun. @@ -75,6 +76,7 @@ Weather forecast for tonight : dark. Apple: you can buy better, but you can't pay more. Subcalifragilisticexpialidocious. Auntie Em: Hate you, hate Kansas. Took the dog. Dorothy." +SKIP= testing "cut empty field" "cut -d ':' -f 1-3" "a::b\n" "" "a::b\n" testing "cut empty field 2" "cut -d ':' -f 3-5" "b::c\n" "" "a::b::c:d\n" -- cgit v1.2.3-55-g6feb From ac2d4d88ce54d418b579a50ae18434fbf5ffa58a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Aug 2021 20:23:40 +0200 Subject: touch: fix SEGV if !ENABLE_FEATURE_TOUCH_SUSV3 Signed-off-by: Denys Vlasenko --- coreutils/touch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coreutils/touch.c b/coreutils/touch.c index ec12eb7cf..78100ba1d 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -127,6 +127,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) #endif ); +#if ENABLE_FEATURE_TOUCH_SUSV3 timebuf[0].tv_nsec = timebuf[1].tv_nsec = UTIME_NOW; if (opts & OPT_r) { struct stat stbuf; @@ -160,6 +161,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) timebuf[1].tv_nsec = UTIME_OMIT; if ((opts & (OPT_a|OPT_m)) == OPT_m) timebuf[0].tv_nsec = UTIME_OMIT; +#endif argv += optind; do { -- cgit v1.2.3-55-g6feb From 319e20b56b281c9ce552f918b1a1d4c5577d38d6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Aug 2021 20:41:18 +0200 Subject: taskset: disallow "taskset -p 0" Signed-off-by: Denys Vlasenko --- util-linux/taskset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util-linux/taskset.c b/util-linux/taskset.c index afe2f04d2..d2ef9b98f 100644 --- a/util-linux/taskset.c +++ b/util-linux/taskset.c @@ -218,7 +218,7 @@ static int process_pid_str(const char *pid_str, unsigned opts, char *aff) ul *mask; unsigned mask_size_in_bytes; const char *current_new; - pid_t pid = xatoi_positive(pid_str); + pid_t pid = !pid_str ? 0 : xatou_range(pid_str, 1, INT_MAX); /* disallow "0": "taskset -p 0" should fail */ mask_size_in_bytes = SZOF_UL; current_new = "current"; @@ -343,7 +343,7 @@ int taskset_main(int argc UNUSED_PARAM, char **argv) /* */ if (!*argv) bb_show_usage(); - process_pid_str("0", opts, aff); + process_pid_str(NULL, opts, aff); BB_EXECVP_or_die(argv); } -- cgit v1.2.3-55-g6feb From d32ef3174bdcad429680b393372cb49fa8144289 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Aug 2021 20:50:13 +0200 Subject: *: remove remains of FEATURE_TOUCH_NODEREF Signed-off-by: Denys Vlasenko --- configs/android_502_defconfig | 2 -- configs/android_ndk_defconfig | 1 - scripts/randomtest | 2 -- 3 files changed, 5 deletions(-) diff --git a/configs/android_502_defconfig b/configs/android_502_defconfig index 503157c12..104e70f23 100644 --- a/configs/android_502_defconfig +++ b/configs/android_502_defconfig @@ -33,7 +33,6 @@ ## Assorted header problems: ## # CONFIG_HOSTID is not set ## # CONFIG_FEATURE_SYNC_FANCY is not set - syncfs() -## # CONFIG_FEATURE_TOUCH_NODEREF is not set - lutimes() ## # CONFIG_LOGNAME is not set - getlogin_r() ## # CONFIG_LOADFONT is not set ## # CONFIG_SETFONT is not set @@ -269,7 +268,6 @@ CONFIG_SYNC=y CONFIG_TEST=y CONFIG_FEATURE_TEST_64=y CONFIG_TOUCH=y -# CONFIG_FEATURE_TOUCH_NODEREF is not set CONFIG_FEATURE_TOUCH_SUSV3=y CONFIG_TR=y CONFIG_FEATURE_TR_CLASSES=y diff --git a/configs/android_ndk_defconfig b/configs/android_ndk_defconfig index 03d497d2e..425593454 100644 --- a/configs/android_ndk_defconfig +++ b/configs/android_ndk_defconfig @@ -193,7 +193,6 @@ CONFIG_SYNC=y CONFIG_TEST=y CONFIG_FEATURE_TEST_64=y CONFIG_TOUCH=y -# CONFIG_FEATURE_TOUCH_NODEREF is not set CONFIG_FEATURE_TOUCH_SUSV3=y CONFIG_TR=y CONFIG_FEATURE_TR_CLASSES=y diff --git a/scripts/randomtest b/scripts/randomtest index 76550d267..f6e0c9d8c 100755 --- a/scripts/randomtest +++ b/scripts/randomtest @@ -83,7 +83,6 @@ if test x"$LIBC" = x"uclibc"; then \ | grep -v CONFIG_FEATURE_2_4_MODULES \ | grep -v CONFIG_FEATURE_SYNC_FANCY \ - | grep -v CONFIG_FEATURE_TOUCH_NODEREF \ | grep -v CONFIG_NANDWRITE \ | grep -v CONFIG_NANDDUMP \ | grep -v CONFIG_BLKDISCARD \ @@ -100,7 +99,6 @@ if test x"$LIBC" = x"uclibc"; then echo '# CONFIG_PIE is not set' >>.config echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config echo '# CONFIG_FEATURE_SYNC_FANCY is not set' >>.config - echo '# CONFIG_FEATURE_TOUCH_NODEREF is not set' >>.config # My uclibc installation does not support some needed APIs... echo '# CONFIG_NANDWRITE is not set' >>.config echo '# CONFIG_NANDDUMP is not set' >>.config -- cgit v1.2.3-55-g6feb From b259415b51e73cf268a6cb22f0105756f7197781 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Aug 2021 23:01:33 +0200 Subject: dd: fix testsuite Signed-off-by: Denys Vlasenko --- testsuite/dd/dd-count-bytes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testsuite/dd/dd-count-bytes b/testsuite/dd/dd-count-bytes index 0730cba5e..ae1b6c50a 100644 --- a/testsuite/dd/dd-count-bytes +++ b/testsuite/dd/dd-count-bytes @@ -1 +1,3 @@ +# FEATURE: CONFIG_FEATURE_DD_IBS_OBS + test "$(echo I WANT | busybox dd count=3 iflag=count_bytes 2>/dev/null)" = "I W" -- cgit v1.2.3-55-g6feb From 1ce60699c15e5fc2ecff5db40ea1e1ae583b8b34 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Aug 2021 23:05:30 +0200 Subject: dd: tweak --help Signed-off-by: Denys Vlasenko --- coreutils/dd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreutils/dd.c b/coreutils/dd.c index a243f718b..06c1b7b9c 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -56,8 +56,8 @@ //kbuild:lib-$(CONFIG_DD) += dd.o //usage:#define dd_trivial_usage -//usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]\n" -//usage: IF_FEATURE_DD_IBS_OBS( +//usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]" +//usage: IF_FEATURE_DD_IBS_OBS("\n" //usage: " [conv=notrunc|noerror|sync|fsync]\n" //usage: " [iflag=skip_bytes|count_bytes|fullblock|direct] [oflag=seek_bytes|append|direct]" //usage: ) -- cgit v1.2.3-55-g6feb From 8d718686f7dc5ce765544dcb8c7d2d5bc40b9d01 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Aug 2021 00:48:50 +0200 Subject: tar: fix testsuite Signed-off-by: Denys Vlasenko --- testsuite/tar.tests | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/testsuite/tar.tests b/testsuite/tar.tests index d71a34910..0f2e89112 100755 --- a/testsuite/tar.tests +++ b/testsuite/tar.tests @@ -3,6 +3,7 @@ # Licensed under GPLv2, see file LICENSE in this source tree. . ./testing.sh +test -f "$bindir/.config" && . "$bindir/.config" unset LANG unset LANGUAGE @@ -12,7 +13,7 @@ umask 022 # testing "test name" "script" "expected result" "file input" "stdin" -testing "Empty file is not a tarball" '\ +testing "tar Empty file is not a tarball" '\ tar xvf - 2>&1; echo $? ' "\ tar: short read @@ -25,7 +26,7 @@ optional FEATURE_SEAMLESS_GZ GUNZIP # In NOMMU case, "invalid magic" message comes from gunzip child process. # Otherwise, it comes from tar. # Need to fix output up to avoid false positive. -testing "Empty file is not a tarball.tar.gz" '\ +testing "tar Empty file is not a tarball.tar.gz" '\ { tar xvzf - 2>&1; echo $?; } | grep -Fv "invalid magic" ' "\ tar: short read @@ -34,7 +35,7 @@ tar: short read "" "" SKIP= -testing "Two zeroed blocks is a ('truncated') empty tarball" '\ +testing "tar Two zeroed blocks is a ('truncated') empty tarball" '\ dd if=/dev/zero bs=512 count=2 2>/dev/null | tar xvf - 2>&1; echo $? ' "\ 0 @@ -42,7 +43,7 @@ dd if=/dev/zero bs=512 count=2 2>/dev/null | tar xvf - 2>&1; echo $? "" "" SKIP= -testing "Twenty zeroed blocks is an empty tarball" '\ +testing "tar Twenty zeroed blocks is an empty tarball" '\ dd if=/dev/zero bs=512 count=20 2>/dev/null | tar xvf - 2>&1; echo $? ' "\ 0 @@ -313,9 +314,10 @@ l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI= SKIP= cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null +if test x"$CONFIG_UNICODE_USING_LOCALE" != x"y"; then mkdir tar.tempdir && cd tar.tempdir || exit 1 optional UNICODE_SUPPORT FEATURE_TAR_GNU_EXTENSIONS FEATURE_SEAMLESS_BZ2 FEATURE_TAR_AUTODETECT -testing "Pax-encoded UTF8 names and symlinks" '\ +testing "tar Pax-encoded UTF8 names and symlinks" '\ tar xvf ../tar.utf8.tar.bz2 2>&1; echo $? export LANG=en_US.UTF-8 ls -l etc/ssl/certs/* | sed "s:.*etc/:etc/:" | sort @@ -334,10 +336,11 @@ etc/ssl/certs/f80cc7f6.0 -> EBG_Elektronik_Sertifika_Hizmet_Sağlayıcısı.pem "" "" SKIP= cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null +fi mkdir tar.tempdir && cd tar.tempdir || exit 1 optional FEATURE_SEAMLESS_BZ2 FEATURE_TAR_AUTODETECT LS -testing "Symlink attack: create symlink and then write through it" '\ +testing "tar Symlink attack: create symlink and then write through it" '\ exec 2>&1 uudecode -o input && tar xvf input; echo $? ls /tmp/bb_test_evilfile @@ -367,7 +370,7 @@ cd .. || exit 1; rm -rf tar.tempdir 2>/dev/null mkdir tar.tempdir && cd tar.tempdir || exit 1 optional FEATURE_TAR_CREATE -testing "Symlinks and hardlinks coexist" '\ +testing "tar Symlinks and hardlinks coexist" '\ mkdir dir >dir/a ln -s ../dir/a dir/b -- cgit v1.2.3-55-g6feb From d6a7203042a568064ae76cdc2d441e5a399a33c7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Aug 2021 01:31:32 +0200 Subject: vi: fix compile-time error if !ENABLE_FEATURE_VI_SETOPTS Signed-off-by: Denys Vlasenko --- editors/vi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/editors/vi.c b/editors/vi.c index 23a44d597..3e1bd0820 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -320,6 +320,7 @@ struct globals { #define autoindent (0) #define expandtab (0) #define err_method (0) +#define ignorecase (0) #endif #if ENABLE_FEATURE_VI_READONLY -- cgit v1.2.3-55-g6feb From 8e8cea2a1bc5cf0550f6032abc30593d9a62e58c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Aug 2021 07:37:22 +0200 Subject: awk: fix testsuite Signed-off-by: Denys Vlasenko --- testsuite/awk.tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/awk.tests b/testsuite/awk.tests index f53b1efe2..dc2ae2e11 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests @@ -410,7 +410,7 @@ testing "awk printf('%c') can output NUL" \ "awk '{printf(\"hello%c null\n\", 0)}'" "hello\0 null\n" "" "\n" SKIP= -optional FEATURE_AWK_GNU_EXTENSIONS +optional FEATURE_AWK_GNU_EXTENSIONS DESKTOP testing "awk printf('%-10c') can output NUL" \ "awk 'BEGIN { printf \"[%-10c]\n\", 0 }' | od -tx1" "\ 0000000 5b 00 20 20 20 20 20 20 20 20 20 5d 0a -- cgit v1.2.3-55-g6feb From 59243a86d97b793bd4e2c98911fd3a7e41af34c4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Aug 2021 08:53:42 +0200 Subject: busybox: fix "busybox --help busybox" not showing correct text Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 2feed64dd..14be33603 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -893,7 +893,11 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) if (strcmp(argv[1], "--help") == 0) { /* "busybox --help []" */ - if (!argv[2]) + if (!argv[2] +# if ENABLE_FEATURE_SH_STANDALONE && ENABLE_FEATURE_TAB_COMPLETION + || strcmp(argv[2], "busybox") == 0 /* prevent getting "No help available" */ +# endif + ) goto help; /* convert to " --help" */ applet_name = argv[0] = argv[2]; -- cgit v1.2.3-55-g6feb From 9ba502456f92160af4caebe06b96077f2021b3ac Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Aug 2021 11:13:30 +0200 Subject: fdisk: indentation fix Signed-off-by: Denys Vlasenko --- util-linux/fdisk_sun.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c index 427b9487b..66e434833 100644 --- a/util-linux/fdisk_sun.c +++ b/util-linux/fdisk_sun.c @@ -292,10 +292,10 @@ create_sunlabel(void) } else { g_heads = read_int(1, g_heads, 1024, 0, "Heads"); g_sectors = read_int(1, g_sectors, 1024, 0, "Sectors/track"); - if (g_cylinders) - g_cylinders = read_int(1, g_cylinders - 2, 65535, 0, "Cylinders"); - else - g_cylinders = read_int(1, 0, 65535, 0, "Cylinders"); + if (g_cylinders) + g_cylinders = read_int(1, g_cylinders - 2, 65535, 0, "Cylinders"); + else + g_cylinders = read_int(1, 0, 65535, 0, "Cylinders"); sunlabel->nacyl = SUN_SSWAP16(read_int(0, 2, 65535, 0, "Alternate cylinders")); sunlabel->pcylcount = SUN_SSWAP16(read_int(0, g_cylinders + SUN_SSWAP16(sunlabel->nacyl), 65535, 0, "Physical cylinders")); sunlabel->rspeed = SUN_SSWAP16(read_int(1, 5400, 100000, 0, "Rotation speed (rpm)")); -- cgit v1.2.3-55-g6feb From 540aa116615713ad53e5ac98850993162e27c32d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Aug 2021 20:03:07 +0200 Subject: scripts/randomtest.loop: let user know about SKIP_MOUNT_MAND_TESTS Signed-off-by: Denys Vlasenko --- scripts/randomtest.loop | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/randomtest.loop b/scripts/randomtest.loop index edfbc5c58..c6d2cdcda 100755 --- a/scripts/randomtest.loop +++ b/scripts/randomtest.loop @@ -6,13 +6,18 @@ run_testsuite=true run_single_test=false run_single_test=true -test -d "$1" || { echo "'$1' is not a directory"; exit 1; } -test -x "$1/scripts/randomtest" || { echo "No scripts/randomtest in '$1'"; exit 1; } - export LIBC="uclibc" export CROSS_COMPILER_PREFIX="i686-" export MAKEOPTS="-j9" +test -d "$1" || { echo "'$1' is not a directory"; exit 1; } +test -x "$1/scripts/randomtest" || { echo "No scripts/randomtest in '$1'"; exit 1; } + +test "$SKIP_MOUNT_MAND_TESTS" = "1" || { + echo "SKIP_MOUNT_MAND_TESTS not set, some mount tests will fail" + echo "if current kernel has CONFIG_MANDATORY_FILE_LOCKING off." +} + cnt=0 fail=0 while sleep 1; do -- cgit v1.2.3-55-g6feb