mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 07:43:07 +02:00
a select command invalid selection variable name is now a fatal error in posix mode; many test suite additions
This commit is contained in:
@@ -7652,3 +7652,28 @@ lib/readline/readline.h
|
||||
|
||||
lib/readline/doc/rltech.texi
|
||||
- rl_reparse_colors: document as public function
|
||||
|
||||
9/21
|
||||
----
|
||||
pcomplete.c
|
||||
- it_init_aliases: move the free (alias_list) inside #ifdef ALIAS.
|
||||
Report and fix from Mike Jonkmans <bashbug@jonkmans.nl>
|
||||
|
||||
redir.c
|
||||
- redirection_error: set W_NOPROCSUB in the word redirection_error
|
||||
creates to call redirection_expand
|
||||
|
||||
builtins/bind.def
|
||||
- bind_builtin: use CASE_HELPOPT so the long doc gets printed when
|
||||
--help is supplied
|
||||
|
||||
builtins/getopts.def
|
||||
- getopts_builtin: change to use no_options()
|
||||
|
||||
9/22
|
||||
----
|
||||
execute_cmd.c
|
||||
- execute_select_command: in posix mode, an invalid selection variable
|
||||
name is a fatal error, just like with `for'. This is compatible with
|
||||
ksh93 and mksh
|
||||
|
||||
|
||||
@@ -950,6 +950,7 @@ tests/arith5.sub f
|
||||
tests/arith6.sub f
|
||||
tests/arith7.sub f
|
||||
tests/arith8.sub f
|
||||
tests/arith9.sub f
|
||||
tests/array.tests f
|
||||
tests/array.right f
|
||||
tests/array1.sub f
|
||||
@@ -1023,6 +1024,7 @@ tests/builtins5.sub f
|
||||
tests/builtins6.sub f
|
||||
tests/builtins7.sub f
|
||||
tests/builtins8.sub f
|
||||
tests/builtins9.sub f
|
||||
tests/source1.sub f
|
||||
tests/source2.sub f
|
||||
tests/source3.sub f
|
||||
@@ -1075,9 +1077,11 @@ tests/comsub-posix5.sub f
|
||||
tests/comsub-posix6.sub f
|
||||
tests/cond.tests f
|
||||
tests/cond.right f
|
||||
tests/cond-error1.sub f
|
||||
tests/cond-regexp1.sub f
|
||||
tests/cond-regexp2.sub f
|
||||
tests/cond-regexp3.sub f
|
||||
tests/cond-xtrace1.sub f
|
||||
tests/coproc.tests f
|
||||
tests/coproc.right f
|
||||
tests/cprint.tests f
|
||||
@@ -1216,6 +1220,7 @@ tests/glob7.sub f
|
||||
tests/glob8.sub f
|
||||
tests/glob9.sub f
|
||||
tests/glob10.sub f
|
||||
tests/glob11.sub f
|
||||
tests/glob.right f
|
||||
tests/globstar.tests f
|
||||
tests/globstar.right f
|
||||
@@ -1271,6 +1276,8 @@ tests/intl2.sub f
|
||||
tests/intl3.sub f
|
||||
tests/intl4.sub f
|
||||
tests/intl.right f
|
||||
tests/invocation.tests f
|
||||
tests/invocation.right f
|
||||
tests/iquote.tests f
|
||||
tests/iquote.right f
|
||||
tests/iquote1.sub f
|
||||
@@ -1487,6 +1494,7 @@ tests/run-ifs f
|
||||
tests/run-ifs-posix f
|
||||
tests/run-input-test f
|
||||
tests/run-intl f
|
||||
tests/run-invocation f
|
||||
tests/run-iquote f
|
||||
tests/run-invert f
|
||||
tests/run-jobs f
|
||||
@@ -1559,6 +1567,7 @@ tests/trap4.sub f
|
||||
tests/trap5.sub f
|
||||
tests/trap6.sub f
|
||||
tests/trap7.sub f
|
||||
tests/trap8.sub f
|
||||
tests/type.tests f
|
||||
tests/type.right f
|
||||
tests/type1.sub f
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@ bind_builtin (WORD_LIST *list)
|
||||
case 'X':
|
||||
flags |= XXFLAG;
|
||||
break;
|
||||
case GETOPT_HELP:
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
BIND_RETURN (EX_USAGE);
|
||||
|
||||
@@ -124,6 +124,10 @@ command_builtin (WORD_LIST *list)
|
||||
|
||||
#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0))
|
||||
|
||||
/* This code isn't executed any more; look at execute_cmd.c:execute_simple_command()
|
||||
where command is treated as a pseudo-reserved prefix so we can optimize
|
||||
away forks where possible. */
|
||||
|
||||
/* We don't want this to be reparsed (consider command echo 'foo &'), so
|
||||
just make a simple_command structure and call execute_command with it. */
|
||||
command = make_bare_simple_command (line_number);
|
||||
@@ -134,8 +138,8 @@ command_builtin (WORD_LIST *list)
|
||||
|
||||
add_unwind_protect (uw_dispose_command, command);
|
||||
result = execute_command (command);
|
||||
dispose_command (command);
|
||||
|
||||
run_unwind_frame ("command_builtin");
|
||||
|
||||
discard_unwind_frame ("command_builtin");
|
||||
return (result);
|
||||
}
|
||||
|
||||
+4
-11
@@ -312,23 +312,16 @@ getopts_builtin (WORD_LIST *list)
|
||||
char **av;
|
||||
int ac, ret;
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
list = loptend; /* skip over possible `--' */
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_usage ();
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
reset_internal_getopt ();
|
||||
if ((ret = internal_getopt (list, "")) != -1)
|
||||
{
|
||||
if (ret == GETOPT_HELP)
|
||||
builtin_help ();
|
||||
else
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
list = loptend;
|
||||
|
||||
av = make_builtin_argv (list, &ac);
|
||||
ret = dogetopts (ac, av);
|
||||
free ((char *)av);
|
||||
|
||||
+1
-1
@@ -8598,7 +8598,7 @@ command in which the error occurred").
|
||||
@item
|
||||
A non-interactive shell exits with an error status if the iteration
|
||||
variable in a @code{for} statement or the selection variable in a
|
||||
@code{select} statement is a readonly variable.
|
||||
@code{select} statement is a readonly variable or has an invalid name.
|
||||
|
||||
@item
|
||||
Non-interactive shells exit if @var{filename} in @code{.} @var{filename}
|
||||
|
||||
+8
-1
@@ -3416,7 +3416,14 @@ execute_select_command (SELECT_COM *select_command)
|
||||
int retval, list_len, show_menu, save_line_number;
|
||||
|
||||
if (check_identifier (select_command->name, 1) == 0)
|
||||
return (EXECUTION_FAILURE);
|
||||
{
|
||||
if (posixly_correct && interactive_shell == 0)
|
||||
{
|
||||
last_command_exit_value = EX_BADUSAGE;
|
||||
jump_to_top_level (ERREXIT);
|
||||
}
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
save_line_number = line_number;
|
||||
line_number = select_command->line;
|
||||
|
||||
+1
-1
@@ -365,10 +365,10 @@ it_init_aliases (ITEMLIST *itp)
|
||||
sl->list[n] = (char *)NULL;
|
||||
sl->list_size = sl->list_len = n;
|
||||
itp->slist = sl;
|
||||
free (alias_list);
|
||||
#else
|
||||
itp->slist = (STRINGLIST *)NULL;
|
||||
#endif
|
||||
free (alias_list);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ redirection_error (REDIRECT *temp, int error, char *fn)
|
||||
oflags = temp->redirectee.filename->flags;
|
||||
if (posixly_correct && interactive_shell == 0)
|
||||
temp->redirectee.filename->flags |= W_NOGLOB;
|
||||
temp->redirectee.filename->flags |= W_NOCOMSUB;
|
||||
temp->redirectee.filename->flags |= W_NOCOMSUB|W_NOPROCSUB;
|
||||
filename = allocname = redirection_expand (temp->redirectee.filename);
|
||||
temp->redirectee.filename->flags = oflags;
|
||||
if (filename == 0)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
alias: 0
|
||||
alias: 0
|
||||
./alias.tests: line 38: qfoo: command not found
|
||||
./alias.tests: line 44: unalias: foo: not found
|
||||
quux
|
||||
hi
|
||||
declare -a m=([0]="x")
|
||||
|
||||
@@ -40,6 +40,8 @@ qfoo
|
||||
unalias qfoo qbar qbaz quux
|
||||
|
||||
unalias -a
|
||||
# error
|
||||
unalias foo
|
||||
|
||||
alias foo='echo '
|
||||
alias bar=baz
|
||||
|
||||
+59
-27
@@ -51,6 +51,7 @@
|
||||
1
|
||||
1
|
||||
32
|
||||
32
|
||||
4
|
||||
20
|
||||
1,i+=2
|
||||
@@ -60,7 +61,7 @@
|
||||
1,i+=2
|
||||
30
|
||||
1,j+=2
|
||||
./arith.tests: line 127: 1 ? 20 : x+=2: attempted assignment to non-variable (error token is "+=2")
|
||||
./arith.tests: line 129: 1 ? 20 : x+=2: attempted assignment to non-variable (error token is "+=2")
|
||||
20
|
||||
6
|
||||
6,5,3
|
||||
@@ -70,6 +71,8 @@
|
||||
127
|
||||
36
|
||||
40
|
||||
40
|
||||
40
|
||||
10
|
||||
10
|
||||
10
|
||||
@@ -80,16 +83,18 @@
|
||||
36
|
||||
62
|
||||
63
|
||||
./arith.tests: line 162: 3425#56: invalid arithmetic base (error token is "3425#56")
|
||||
./arith.tests: line 165: 2#: invalid integer constant (error token is "2#")
|
||||
./arith.tests: line 168: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ")
|
||||
./arith.tests: line 169: 2#44: value too great for base (error token is "2#44")
|
||||
./arith.tests: line 170: 44 / 0 : division by 0 (error token is "0 ")
|
||||
./arith.tests: line 171: let: jv += $iv: arithmetic syntax error: operand expected (error token is "$iv")
|
||||
./arith.tests: line 172: jv += $iv : arithmetic syntax error: operand expected (error token is "$iv ")
|
||||
./arith.tests: line 173: let: rv = 7 + (43 * 6: missing `)' (error token is "6")
|
||||
./arith.tests: line 177: 0#4: invalid number (error token is "0#4")
|
||||
./arith.tests: line 178: 2#110#11: invalid number (error token is "2#110#11")
|
||||
./arith.tests: line 168: 3425#56: invalid arithmetic base (error token is "3425#56")
|
||||
./arith.tests: line 171: 2#: invalid integer constant (error token is "2#")
|
||||
./arith.tests: line 174: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ")
|
||||
./arith.tests: line 175: 2#44: value too great for base (error token is "2#44")
|
||||
./arith.tests: line 176: 44 / 0 : division by 0 (error token is "0 ")
|
||||
./arith.tests: line 177: let: jv += $iv: arithmetic syntax error: operand expected (error token is "$iv")
|
||||
./arith.tests: line 178: jv += $iv : arithmetic syntax error: operand expected (error token is "$iv ")
|
||||
./arith.tests: line 179: let: rv = 7 + (43 * 6: missing `)' (error token is "6")
|
||||
./arith.tests: line 182: b / 0 : division by 0 (error token is "0 ")
|
||||
./arith.tests: line 183: b /= 0 : division by 0 (error token is "0 ")
|
||||
./arith.tests: line 188: 0#4: invalid number (error token is "0#4")
|
||||
./arith.tests: line 189: 2#110#11: invalid number (error token is "2#110#11")
|
||||
abc
|
||||
def
|
||||
ghi
|
||||
@@ -97,15 +102,15 @@ ok
|
||||
6
|
||||
1
|
||||
0
|
||||
./arith.tests: line 196: 4 + : arithmetic syntax error: operand expected (error token is "+ ")
|
||||
./arith.tests: line 207: 4 + : arithmetic syntax error: operand expected (error token is "+ ")
|
||||
16
|
||||
./arith.tests: line 201: 4 ? : 3 + 5 : expression expected (error token is ": 3 + 5 ")
|
||||
./arith.tests: line 202: 1 ? 20 : `:' expected for conditional expression (error token is "20 ")
|
||||
./arith.tests: line 203: 4 ? 20 : : expression expected (error token is ": ")
|
||||
./arith.tests: line 212: 4 ? : 3 + 5 : expression expected (error token is ": 3 + 5 ")
|
||||
./arith.tests: line 213: 1 ? 20 : `:' expected for conditional expression (error token is "20 ")
|
||||
./arith.tests: line 214: 4 ? 20 : : expression expected (error token is ": ")
|
||||
9
|
||||
./arith.tests: line 209: 0 && B=42 : attempted assignment to non-variable (error token is "=42 ")
|
||||
./arith.tests: line 220: 0 && B=42 : attempted assignment to non-variable (error token is "=42 ")
|
||||
9
|
||||
./arith.tests: line 212: 1 || B=88 : attempted assignment to non-variable (error token is "=88 ")
|
||||
./arith.tests: line 223: 1 || B=88 : attempted assignment to non-variable (error token is "=88 ")
|
||||
9
|
||||
0
|
||||
9
|
||||
@@ -121,6 +126,7 @@ ok
|
||||
131072
|
||||
2147483647
|
||||
1
|
||||
./arith.tests: line 255: 2**-1 : exponent less than 0 (error token is "1 ")
|
||||
4
|
||||
4
|
||||
5
|
||||
@@ -131,16 +137,17 @@ ok
|
||||
4
|
||||
4
|
||||
7
|
||||
./arith.tests: line 260: 7-- : arithmetic syntax error: operand expected (error token is "- ")
|
||||
./arith.tests: line 262: --x=7 : attempted assignment to non-variable (error token is "=7 ")
|
||||
./arith.tests: line 263: ++x=7 : attempted assignment to non-variable (error token is "=7 ")
|
||||
./arith.tests: line 265: x++=7 : attempted assignment to non-variable (error token is "=7 ")
|
||||
./arith.tests: line 266: x--=7 : attempted assignment to non-variable (error token is "=7 ")
|
||||
./arith.tests: line 274: 7-- : arithmetic syntax error: operand expected (error token is "- ")
|
||||
./arith.tests: line 276: --x=7 : attempted assignment to non-variable (error token is "=7 ")
|
||||
./arith.tests: line 277: ++x=7 : attempted assignment to non-variable (error token is "=7 ")
|
||||
./arith.tests: line 279: x++=7 : attempted assignment to non-variable (error token is "=7 ")
|
||||
./arith.tests: line 280: x--=7 : attempted assignment to non-variable (error token is "=7 ")
|
||||
4
|
||||
7
|
||||
-7
|
||||
7
|
||||
7
|
||||
./arith.tests: line 292: --x++ : ++: assignment requires lvalue (error token is "++ ")
|
||||
2
|
||||
2
|
||||
./arith1.sub: line 15: 4-- : arithmetic syntax error: operand expected (error token is "- ")
|
||||
@@ -249,15 +256,40 @@ efg
|
||||
0
|
||||
0
|
||||
0
|
||||
./arith9.sub: line 4: a: unbound variable
|
||||
./arith9.sub: line 5: a: unbound variable
|
||||
0
|
||||
after 3 0
|
||||
0
|
||||
after 4 0
|
||||
./arith9.sub: line 14: b: expression recursion level exceeded (error token is "b")
|
||||
+ var=42
|
||||
+ echo 42
|
||||
42
|
||||
+ echo 0
|
||||
0
|
||||
+ echo 0
|
||||
0
|
||||
+ echo 0
|
||||
0
|
||||
+ (( 42 ))
|
||||
+ echo 0
|
||||
0
|
||||
+ (( ))
|
||||
+ echo 1
|
||||
1
|
||||
+ set +x
|
||||
./arith9.sub: line 37: 4+: arithmetic syntax error: operand expected (error token is "+")
|
||||
x = 4+ y =
|
||||
8 12
|
||||
./arith.tests: line 310: ((: x=9 y=41 : arithmetic syntax error in expression (error token is "y=41 ")
|
||||
./arith.tests: line 314: a b: arithmetic syntax error in expression (error token is "b")
|
||||
./arith.tests: line 315: ((: a b: arithmetic syntax error in expression (error token is "b")
|
||||
./arith.tests: line 332: ((: x=9 y=41 : arithmetic syntax error in expression (error token is "y=41 ")
|
||||
./arith.tests: line 336: a b: arithmetic syntax error in expression (error token is "b")
|
||||
./arith.tests: line 337: ((: a b: arithmetic syntax error in expression (error token is "b")
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
./arith.tests: line 330: 'foo' : arithmetic syntax error: operand expected (error token is "'foo' ")
|
||||
./arith.tests: line 333: b[c]d: arithmetic syntax error in expression (error token is "d")
|
||||
./arith.tests: line 352: 'foo' : arithmetic syntax error: operand expected (error token is "'foo' ")
|
||||
./arith.tests: line 355: b[c]d: arithmetic syntax error in expression (error token is "d")
|
||||
|
||||
@@ -97,6 +97,8 @@ echo $(( 4<(2+3) ? 1 : 32))
|
||||
echo $(( (2+2)<(2+3) ? 1 : 32))
|
||||
echo $(( (2+2)>(2+3) ? 1 : 32))
|
||||
|
||||
echo $(( (2+2)>(2+3) ? 2**0 : 32))
|
||||
|
||||
# bug in bash versions through bash-3.2
|
||||
S=105
|
||||
W=$((S>99?4:S>9?3:S>0?2:0))
|
||||
@@ -143,6 +145,10 @@ echo $(( 16#FF/2 ))
|
||||
echo $(( 8#44 ))
|
||||
|
||||
echo $(( 8 ^ 32 ))
|
||||
a=8
|
||||
echo $(( a ^ 32 ))
|
||||
echo $(( a ^= 32 ))
|
||||
unset -v a
|
||||
|
||||
# other bases
|
||||
echo $(( 16#a ))
|
||||
@@ -172,6 +178,11 @@ let 'jv += $iv'
|
||||
echo $(( jv += \$iv ))
|
||||
let 'rv = 7 + (43 * 6'
|
||||
|
||||
b=44
|
||||
echo $(( b / 0 ))
|
||||
echo $(( b /= 0 ))
|
||||
unset -v b
|
||||
|
||||
# more errors
|
||||
declare -i i
|
||||
i=0#4
|
||||
@@ -240,6 +251,9 @@ echo $(( 2**16*2 ))
|
||||
echo $(( 2**31-1))
|
||||
echo $(( 2**0 ))
|
||||
|
||||
# error
|
||||
echo $(( 2**-1 ))
|
||||
|
||||
# {pre,post}-{inc,dec}rement and associated errors
|
||||
|
||||
x=4
|
||||
@@ -273,6 +287,11 @@ echo $(( -7 ))
|
||||
echo $(( ++7 ))
|
||||
echo $(( --7 ))
|
||||
|
||||
unset -v x
|
||||
x=8
|
||||
echo $(( --x++ )) # error
|
||||
unset -v x
|
||||
|
||||
# combinations of expansions
|
||||
echo $(( "`echo 1+1`" ))
|
||||
echo $(( `echo 1+1` ))
|
||||
@@ -299,6 +318,9 @@ ${THIS_SH} ./arith7.sub
|
||||
# problems with evaluation of conditional expressions
|
||||
${THIS_SH} ./arith8.sub
|
||||
|
||||
# expressions with unset variables and nounset enabled
|
||||
${THIS_SH} ./arith9.sub
|
||||
|
||||
x=4
|
||||
y=7
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# test expression evaluation with unset variables
|
||||
set -u
|
||||
|
||||
( echo $(( a > 4 )) ; echo after 1 ) # error
|
||||
( echo $(( a[0] > 4 )); echo after 2) # error
|
||||
|
||||
set +u
|
||||
( echo $(( a > 4 )) ; echo after 3 $? )
|
||||
( echo $(( a[0] > 4 )); echo after 4 $?)
|
||||
|
||||
# this is a recursion stack error
|
||||
a=b
|
||||
b=a
|
||||
echo $(( a + 7 ))
|
||||
|
||||
# make sure command printing works for arithmetic expansions and commands
|
||||
set -x
|
||||
var=42
|
||||
|
||||
echo $(( $var ))
|
||||
echo $?
|
||||
|
||||
echo $(( $null ))
|
||||
echo $?
|
||||
|
||||
(( $var ))
|
||||
echo $?
|
||||
|
||||
(( $null ))
|
||||
echo $?
|
||||
|
||||
set +x
|
||||
|
||||
# invalid expressions in different cases
|
||||
x=4+
|
||||
declare -i x
|
||||
x+=7 y=4
|
||||
echo x = $x y = $y
|
||||
@@ -399,6 +399,10 @@ bar: array with element zero unset: ok
|
||||
bar: element zero: ok
|
||||
qux: unset array: ok
|
||||
qux: unset array element 0: ok
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
2
|
||||
2
|
||||
2
|
||||
|
||||
@@ -32,3 +32,12 @@ bar[1]=set
|
||||
typeset -a qux
|
||||
[[ -v qux ]] || echo qux: unset array: ok
|
||||
[[ -v qux[0] ]] || echo qux: unset array element 0: ok
|
||||
|
||||
unset -v a
|
||||
a[1]=set
|
||||
|
||||
[[ -v a ]] ; echo $?
|
||||
[[ -v a[1] ]] ; echo $?
|
||||
[[ -v a[@] ]] ; echo $?
|
||||
|
||||
[[ ${#a[@]} > 0 ]]; echo $?
|
||||
|
||||
@@ -58,6 +58,8 @@ a b c d e f g h i j k l m n o p q r s t u v w x y z
|
||||
a c e g i k m o q s u w y
|
||||
z x v t r p n l j h f d b
|
||||
2147483645 2147483646 2147483647 2147483648 2147483649
|
||||
00 01 02 03 04 05 06 07 08 09 10
|
||||
00 02 04 06 08 10
|
||||
10 8 6 4 2 0
|
||||
10 8 6 4 2 0
|
||||
-50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0
|
||||
|
||||
@@ -110,6 +110,10 @@ echo {z..a..-2}
|
||||
# make sure brace expansion handles ints > 2**31 - 1 using intmax_t
|
||||
echo {2147483645..2147483649}
|
||||
|
||||
# want zero-padding here
|
||||
echo {00..10}
|
||||
echo {00..10..2}
|
||||
|
||||
# unwanted zero-padding -- fixed post-bash-4.0
|
||||
echo {10..0..2}
|
||||
echo {10..0..-2}
|
||||
|
||||
+18
-1
@@ -291,4 +291,21 @@ u=rwx,g=rwx,o=rwx
|
||||
u=rwx,g=rwx,o=rwx
|
||||
u=rwx,g=rx,o=rx
|
||||
u=rwx,g=rx,o=rx
|
||||
./builtins.tests: line 287: exit: status: numeric argument required
|
||||
hash: hash table empty
|
||||
./builtins9.sub: line 19: hash: notthere: not found
|
||||
1
|
||||
/nosuchdir/nosuchfile
|
||||
builtin hash -p /nosuchdir/nosuchfile cat
|
||||
builtin hash -p /nosuchdir/nosuchfile cat
|
||||
./builtins9.sub: line 30: hash: notthere: not found
|
||||
./builtins9.sub: line 32: hash: notthere: not found
|
||||
./builtins9.sub: line 33: hash: notthere: not found
|
||||
1
|
||||
./builtins9.sub: line 40: /nosuchdir/nosuchfile: No such file or directory
|
||||
127
|
||||
/nosuchdir/nosuchfile
|
||||
0
|
||||
0
|
||||
found
|
||||
./builtins9.sub: line 52: hash: /: Is a directory
|
||||
./builtins.tests: line 290: exit: status: numeric argument required
|
||||
|
||||
@@ -283,6 +283,9 @@ ${THIS_SH} ./builtins7.sub
|
||||
# POSIX complete symbolic umask tests
|
||||
${THIS_SH} ./builtins8.sub
|
||||
|
||||
# hash tests
|
||||
${THIS_SH} ./builtins9.sub
|
||||
|
||||
# this must be last -- it is a fatal error
|
||||
exit status
|
||||
|
||||
|
||||
+14
-3
@@ -1,3 +1,17 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
umask 022
|
||||
umask u=r+w
|
||||
umask -S
|
||||
@@ -49,6 +63,3 @@ umask -S
|
||||
umask 022
|
||||
umask a+xr
|
||||
umask -S
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# hash printing, deleting tests
|
||||
hash -r # start with empty hash table
|
||||
hash # should be error/warning
|
||||
|
||||
hash -d notthere
|
||||
echo $?
|
||||
|
||||
hash -p /nosuchdir/nosuchfile cat
|
||||
|
||||
hash -t cat
|
||||
hash -lt cat
|
||||
hash -l
|
||||
|
||||
hash -d cat
|
||||
|
||||
hash -d notthere
|
||||
|
||||
hash -lt notthere
|
||||
hash -t notthere
|
||||
|
||||
hash -t cat 2>/dev/null
|
||||
echo $?
|
||||
|
||||
# this should fail
|
||||
hash -p /nosuchdir/nosuchfile cat
|
||||
cat </dev/null
|
||||
echo $?
|
||||
hash -t cat
|
||||
echo $?
|
||||
|
||||
# but with checkhash set, it should not
|
||||
shopt -s checkhash
|
||||
cat </dev/null
|
||||
echo $?
|
||||
{ hash -t cat | grep cat >/dev/null; } && echo found
|
||||
|
||||
hash -r
|
||||
hash -p / root
|
||||
@@ -1,4 +1,6 @@
|
||||
./comsub-eof0.sub: line 5: warning: here-document at line 3 delimited by end-of-file (wanted `EOF')
|
||||
./comsub-eof0.sub: line 4: warning: here-document at line 2 delimited by end-of-file (wanted `EOF')
|
||||
hi
|
||||
./comsub-eof0.sub: line 11: warning: here-document at line 9 delimited by end-of-file (wanted `EOF')
|
||||
hi
|
||||
hi
|
||||
./comsub-eof2.sub: line 2: warning: here-document at line 1 delimited by end-of-file (wanted `EOF')
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
# this works as it should, but with a warning
|
||||
foo=$(cat <<EOF
|
||||
hi
|
||||
EOF)
|
||||
echo $foo
|
||||
unset -v foo
|
||||
# it's only the space before the paren that makes this an error
|
||||
# when I fix it, it will show up here
|
||||
foo=$(cat <<EOF
|
||||
|
||||
@@ -20,6 +20,10 @@ argv[1] = <foo\^Jbar>
|
||||
argv[1] = <foobar>
|
||||
argv[1] = <foo\^Jbar>
|
||||
nested
|
||||
blank ----
|
||||
blank ----
|
||||
blank ----
|
||||
blank ----
|
||||
#esac
|
||||
a
|
||||
ok 1
|
||||
|
||||
@@ -76,6 +76,16 @@ echo $(echo $( echo nested )
|
||||
)
|
||||
)
|
||||
|
||||
# empty comsubs, fork and nofork
|
||||
echo blank --$(
|
||||
)--
|
||||
echo blank --$()--
|
||||
|
||||
echo blank --${
|
||||
}--
|
||||
echo blank --${ }--
|
||||
|
||||
|
||||
BUILDDIR=/builds/test
|
||||
read << EOC
|
||||
Dir: ${BUILDDIR#<(echo a)/}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
: ${THIS_SH:=./bash}
|
||||
|
||||
# all parse errors
|
||||
${THIS_SH} -c '[[ ( -n xx' bash
|
||||
${THIS_SH} -c '[[ ( -n xx )' bash
|
||||
|
||||
${THIS_SH} -c '[[ ( -t X ) ]' bash
|
||||
|
||||
${THIS_SH} -c '[[ -n &' bash
|
||||
${THIS_SH} -c '[[ -n XX &' bash
|
||||
${THIS_SH} -c '[[ -n XX & ]' bash
|
||||
|
||||
${THIS_SH} -c '[[ 4 & ]]' bash
|
||||
${THIS_SH} -c '[[ 4 > & ]]' bash
|
||||
|
||||
${THIS_SH} -c '[[ & ]]' bash
|
||||
${THIS_SH} -c '[[ -Q 7 ]]' bash
|
||||
${THIS_SH} -c '[[ -n < ]]' bash
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# printing conditional commands for xtrace
|
||||
|
||||
set -x
|
||||
|
||||
# error
|
||||
[[ -t X ]]
|
||||
# null operand
|
||||
[[ $b > 7 ]]
|
||||
|
||||
# successful unary operator
|
||||
[[ -n X ]]
|
||||
|
||||
# successful binary operator
|
||||
ivar=42
|
||||
[[ $ivar -eq 42 ]]
|
||||
|
||||
# compound operator, displayed as two unary expressions
|
||||
|
||||
[[ -n a && -n b ]]
|
||||
@@ -147,3 +147,42 @@ ok 5
|
||||
ok 6
|
||||
ok 7
|
||||
ok 8
|
||||
bash: -c: line 1: unexpected token `EOF', expected `)'
|
||||
bash: -c: line 2: syntax error: unexpected end of file
|
||||
bash: -c: line 1: unexpected EOF while looking for `]]'
|
||||
bash: -c: line 2: syntax error: unexpected end of file
|
||||
bash: -c: line 1: syntax error in conditional expression
|
||||
bash: -c: line 1: syntax error near `]'
|
||||
bash: -c: line 1: `[[ ( -t X ) ]'
|
||||
bash: -c: line 1: unexpected argument `&' to conditional unary operator
|
||||
bash: -c: line 1: syntax error near `&'
|
||||
bash: -c: line 1: `[[ -n &'
|
||||
bash: -c: line 1: syntax error in conditional expression: unexpected token `&'
|
||||
bash: -c: line 1: syntax error near `&'
|
||||
bash: -c: line 1: `[[ -n XX &'
|
||||
bash: -c: line 1: syntax error in conditional expression: unexpected token `&'
|
||||
bash: -c: line 1: syntax error near `&'
|
||||
bash: -c: line 1: `[[ -n XX & ]'
|
||||
bash: -c: line 1: unexpected token `&', conditional binary operator expected
|
||||
bash: -c: line 1: syntax error near `&'
|
||||
bash: -c: line 1: `[[ 4 & ]]'
|
||||
bash: -c: line 1: unexpected argument `&' to conditional binary operator
|
||||
bash: -c: line 1: syntax error near `&'
|
||||
bash: -c: line 1: `[[ 4 > & ]]'
|
||||
bash: -c: line 1: unexpected token `&' in conditional command
|
||||
bash: -c: line 1: syntax error near `&'
|
||||
bash: -c: line 1: `[[ & ]]'
|
||||
bash: -c: line 1: conditional binary operator expected
|
||||
bash: -c: line 1: syntax error near `7'
|
||||
bash: -c: line 1: `[[ -Q 7 ]]'
|
||||
bash: -c: line 1: unexpected argument `<' to conditional unary operator
|
||||
bash: -c: line 1: syntax error near `<'
|
||||
bash: -c: line 1: `[[ -n < ]]'
|
||||
+ [[ -t X ]]
|
||||
./cond-xtrace1.sub: line 6: [[: X: integer expected
|
||||
+ [[ '' > 7 ]]
|
||||
+ [[ -n X ]]
|
||||
+ ivar=42
|
||||
+ [[ 42 -eq 42 ]]
|
||||
+ [[ -n a ]]
|
||||
+ [[ -n b ]]
|
||||
|
||||
+3
-2
@@ -230,7 +230,8 @@ del=$'\177'
|
||||
if [[ str ]] then [[ str ]] fi
|
||||
|
||||
${THIS_SH} ./cond-regexp1.sub
|
||||
|
||||
${THIS_SH} ./cond-regexp2.sub
|
||||
|
||||
${THIS_SH} ./cond-regexp3.sub
|
||||
|
||||
${THIS_SH} ./cond-error1.sub
|
||||
${THIS_SH} ./cond-xtrace1.sub
|
||||
|
||||
+101
-78
@@ -5,101 +5,113 @@ unalias: usage: unalias [-a] name [name ...]
|
||||
./errors.tests: line 32: alias: hoowah: not found
|
||||
./errors.tests: line 33: unalias: hoowah: not found
|
||||
./errors.tests: line 36: `1': not a valid identifier
|
||||
./errors.tests: line 37: `f\1': not a valid identifier
|
||||
./errors.tests: line 41: `invalid-name': not a valid identifier
|
||||
./errors.tests: line 43: `f\1': not a valid identifier
|
||||
./errors.tests: line 46: `1': not a valid identifier
|
||||
./errors.tests: line 47: `f\1': not a valid identifier
|
||||
./errors.tests: line 48: `invalid-name': not a valid identifier
|
||||
./errors.tests: line 50: `1': not a valid identifier
|
||||
./errors.tests: line 51: `f\1': not a valid identifier
|
||||
declare -fr func
|
||||
./errors.tests: line 49: func: readonly function
|
||||
./errors.tests: line 52: unset: -x: invalid option
|
||||
./errors.tests: line 64: func: readonly function
|
||||
./errors.tests: line 67: unset: -x: invalid option
|
||||
unset: usage: unset [-f] [-v] [-n] [name ...]
|
||||
./errors.tests: line 55: unset: func: cannot unset: readonly function
|
||||
./errors.tests: line 58: declare: func: readonly function
|
||||
./errors.tests: line 62: declare: -a: invalid option
|
||||
./errors.tests: line 63: declare: -i: invalid option
|
||||
./errors.tests: line 67: unset: XPATH: cannot unset: readonly variable
|
||||
./errors.tests: line 73: unset: cannot simultaneously unset a function and a variable
|
||||
./errors.tests: line 76: declare: -z: invalid option
|
||||
./errors.tests: line 70: unset: func: cannot unset: readonly function
|
||||
./errors.tests: line 73: declare: func: readonly function
|
||||
./errors.tests: line 77: declare: -a: invalid option
|
||||
./errors.tests: line 78: declare: -i: invalid option
|
||||
./errors.tests: line 82: unset: XPATH: cannot unset: readonly variable
|
||||
./errors.tests: line 88: unset: cannot simultaneously unset a function and a variable
|
||||
./errors.tests: line 91: declare: -z: invalid option
|
||||
declare: usage: declare [-aAfFgiIlnrtux] [name[=value] ...] or declare -p [-aAfFilnrtux] [name ...]
|
||||
./errors.tests: line 78: declare: `-z': not a valid identifier
|
||||
./errors.tests: line 79: declare: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 83: declare: cannot use `-f' to make functions
|
||||
./errors.tests: line 86: exec: -i: invalid option
|
||||
./errors.tests: line 93: declare: `-z': not a valid identifier
|
||||
./errors.tests: line 94: declare: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 98: declare: cannot use `-f' to make functions
|
||||
./errors.tests: line 101: exec: -i: invalid option
|
||||
exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
|
||||
./errors.tests: line 90: export: XPATH: not a function
|
||||
./errors.tests: line 93: break: only meaningful in a `for', `while', or `until' loop
|
||||
./errors.tests: line 94: continue: only meaningful in a `for', `while', or `until' loop
|
||||
./errors.tests: line 97: shift: label: numeric argument required
|
||||
./errors.tests: line 102: shift: too many arguments
|
||||
./errors.tests: line 108: let: expression expected
|
||||
./errors.tests: line 111: local: can only be used in a function
|
||||
./errors.tests: line 114: logout: not login shell: use `exit'
|
||||
./errors.tests: line 117: hash: notthere: not found
|
||||
./errors.tests: line 120: hash: -v: invalid option
|
||||
./errors.tests: line 105: export: XPATH: not a function
|
||||
./errors.tests: line 108: break: only meaningful in a `for', `while', or `until' loop
|
||||
./errors.tests: line 109: continue: only meaningful in a `for', `while', or `until' loop
|
||||
./errors.tests: line 112: shift: label: numeric argument required
|
||||
./errors.tests: line 117: shift: too many arguments
|
||||
./errors.tests: line 123: let: expression expected
|
||||
./errors.tests: line 126: local: can only be used in a function
|
||||
./errors.tests: line 129: logout: not login shell: use `exit'
|
||||
./errors.tests: line 132: hash: notthere: not found
|
||||
./errors.tests: line 135: hash: -v: invalid option
|
||||
hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
|
||||
./errors.tests: line 124: hash: hashing disabled
|
||||
./errors.tests: line 127: export: `AA[4]': not a valid identifier
|
||||
./errors.tests: line 128: readonly: `AA[4]': not a valid identifier
|
||||
./errors.tests: line 131: unset: [-2]: bad array subscript
|
||||
./errors.tests: line 135: AA: readonly variable
|
||||
./errors.tests: line 139: AA: readonly variable
|
||||
./errors.tests: line 147: shift: 5: shift count out of range
|
||||
./errors.tests: line 148: shift: -2: shift count out of range
|
||||
./errors.tests: line 151: shopt: no_such_option: invalid shell option name
|
||||
./errors.tests: line 152: shopt: no_such_option: invalid shell option name
|
||||
./errors.tests: line 155: umask: 09: octal number out of range
|
||||
./errors.tests: line 156: umask: `:': invalid symbolic mode character
|
||||
./errors.tests: line 157: umask: `:': invalid symbolic mode operator
|
||||
./errors.tests: line 160: umask: -i: invalid option
|
||||
./errors.tests: line 139: hash: hashing disabled
|
||||
./errors.tests: line 142: export: `AA[4]': not a valid identifier
|
||||
./errors.tests: line 143: readonly: `AA[4]': not a valid identifier
|
||||
./errors.tests: line 146: unset: [-2]: bad array subscript
|
||||
./errors.tests: line 150: AA: readonly variable
|
||||
./errors.tests: line 154: AA: readonly variable
|
||||
./errors.tests: line 162: shift: 5: shift count out of range
|
||||
./errors.tests: line 163: shift: -2: shift count out of range
|
||||
./errors.tests: line 166: shopt: no_such_option: invalid shell option name
|
||||
./errors.tests: line 167: shopt: no_such_option: invalid shell option name
|
||||
./errors.tests: line 170: umask: 09: octal number out of range
|
||||
./errors.tests: line 171: umask: `:': invalid symbolic mode character
|
||||
./errors.tests: line 172: umask: `:': invalid symbolic mode operator
|
||||
./errors.tests: line 175: umask: -i: invalid option
|
||||
umask: usage: umask [-p] [-S] [mode]
|
||||
./errors.tests: line 164: umask: `p': invalid symbolic mode character
|
||||
./errors.tests: line 173: VAR: readonly variable
|
||||
./errors.tests: line 176: declare: VAR: readonly variable
|
||||
./errors.tests: line 177: declare: VAR: readonly variable
|
||||
./errors.tests: line 179: declare: unset: not found
|
||||
./errors.tests: line 182: VAR: readonly variable
|
||||
./errors.tests: line 179: umask: `p': invalid symbolic mode character
|
||||
./errors.tests: line 188: VAR: readonly variable
|
||||
./errors.tests: line 191: declare: VAR: readonly variable
|
||||
./errors.tests: line 192: declare: VAR: readonly variable
|
||||
./errors.tests: line 194: declare: unset: not found
|
||||
./errors.tests: line 197: VAR: readonly variable
|
||||
comsub: -c: line 1: syntax error near unexpected token `)'
|
||||
comsub: -c: line 1: `: $( for z in 1 2 3; do )'
|
||||
comsub: -c: line 1: syntax error near unexpected token `done'
|
||||
comsub: -c: line 1: `: $( for z in 1 2 3; done )'
|
||||
./errors.tests: line 189: cd: HOME not set
|
||||
./errors.tests: line 190: cd: /tmp/xyz.bash: No such file or directory
|
||||
./errors.tests: line 192: cd: OLDPWD not set
|
||||
./errors.tests: line 193: cd: /bin/sh: Not a directory
|
||||
./errors.tests: line 195: cd: /tmp/cd-notthere: No such file or directory
|
||||
./errors.tests: line 198: .: filename argument required
|
||||
./errors.tests: line 204: cd: HOME not set
|
||||
./errors.tests: line 205: cd: /tmp/xyz.bash: No such file or directory
|
||||
./errors.tests: line 207: cd: OLDPWD not set
|
||||
./errors.tests: line 208: cd: /bin/sh: Not a directory
|
||||
./errors.tests: line 210: cd: /tmp/cd-notthere: No such file or directory
|
||||
./errors.tests: line 213: .: filename argument required
|
||||
.: usage: . filename [arguments]
|
||||
./errors.tests: line 199: source: filename argument required
|
||||
./errors.tests: line 214: source: filename argument required
|
||||
source: usage: source filename [arguments]
|
||||
./errors.tests: line 202: .: -i: invalid option
|
||||
./errors.tests: line 217: .: -i: invalid option
|
||||
.: usage: . filename [arguments]
|
||||
./errors.tests: line 205: set: -q: invalid option
|
||||
./errors.tests: line 220: set: -q: invalid option
|
||||
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
|
||||
./errors.tests: line 208: enable: sh: not a shell builtin
|
||||
./errors.tests: line 208: enable: bash: not a shell builtin
|
||||
./errors.tests: line 211: shopt: cannot set and unset shell options simultaneously
|
||||
./errors.tests: line 214: read: var: invalid timeout specification
|
||||
./errors.tests: line 217: read: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 220: VAR: readonly variable
|
||||
./errors.tests: line 223: readonly: -x: invalid option
|
||||
./errors.tests: line 223: enable: sh: not a shell builtin
|
||||
./errors.tests: line 223: enable: bash: not a shell builtin
|
||||
./errors.tests: line 226: shopt: cannot set and unset shell options simultaneously
|
||||
./errors.tests: line 229: read: var: invalid timeout specification
|
||||
./errors.tests: line 232: read: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 235: VAR: readonly variable
|
||||
./errors.tests: line 238: readonly: -x: invalid option
|
||||
readonly: usage: readonly [-aAf] [name[=value] ...] or readonly -p
|
||||
./errors.tests: line 226: eval: -i: invalid option
|
||||
./errors.tests: line 241: eval: -i: invalid option
|
||||
eval: usage: eval [arg ...]
|
||||
./errors.tests: line 227: command: -i: invalid option
|
||||
./errors.tests: line 242: command: -i: invalid option
|
||||
command: usage: command [-pVv] command [arg ...]
|
||||
./errors.tests: line 230: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 231: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 234: trap: NOSIG: invalid signal specification
|
||||
./errors.tests: line 237: trap: -s: invalid option
|
||||
./errors.tests: line 245: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 246: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 249: trap: NOSIG: invalid signal specification
|
||||
./errors.tests: line 252: trap: -s: invalid option
|
||||
trap: usage: trap [-Plp] [[action] signal_spec ...]
|
||||
./errors.tests: line 243: return: can only `return' from a function or sourced script
|
||||
./errors.tests: line 247: break: 0: loop count out of range
|
||||
./errors.tests: line 251: continue: 0: loop count out of range
|
||||
./errors.tests: line 256: builtin: bash: not a shell builtin
|
||||
./errors.tests: line 260: bg: no job control
|
||||
./errors.tests: line 261: fg: no job control
|
||||
./errors.tests: line 264: kill: -s: option requires an argument
|
||||
./errors.tests: line 266: kill: S: invalid signal specification
|
||||
./errors.tests: line 268: kill: `': not a pid or valid job spec
|
||||
./errors.tests: line 258: return: can only `return' from a function or sourced script
|
||||
./errors.tests: line 262: break: 0: loop count out of range
|
||||
./errors.tests: line 266: continue: 0: loop count out of range
|
||||
./errors.tests: line 271: builtin: bash: not a shell builtin
|
||||
./errors.tests: line 275: bg: no job control
|
||||
./errors.tests: line 276: fg: no job control
|
||||
./errors.tests: line 279: kill: -s: option requires an argument
|
||||
./errors.tests: line 281: kill: S: invalid signal specification
|
||||
./errors.tests: line 283: kill: `': not a pid or valid job spec
|
||||
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
|
||||
./errors.tests: line 273: set: trackall: invalid option name
|
||||
./errors.tests: line 277: xx: readonly variable
|
||||
./errors.tests: line 288: set: trackall: invalid option name
|
||||
./errors.tests: line 289: set: -q: invalid option
|
||||
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
|
||||
./errors.tests: line 290: set: -i: invalid option
|
||||
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
|
||||
./errors.tests: line 294: xx: readonly variable
|
||||
1
|
||||
./errors1.sub: line 14: .: -i: invalid option
|
||||
.: usage: . filename [arguments]
|
||||
@@ -115,7 +127,18 @@ TEST
|
||||
2
|
||||
./errors4.sub: line 20: var: readonly variable
|
||||
after readonly assignment
|
||||
./errors4.sub: line 29: break: x: numeric argument required
|
||||
./errors4.sub: line 27: var: readonly variable
|
||||
./errors4.sub: line 31: f: readonly variable
|
||||
./errors4.sub: line 34: var: readonly variable
|
||||
1) 1
|
||||
2) 2
|
||||
3) 3
|
||||
#? ./errors4.sub: line 37: var: readonly variable
|
||||
1) 1
|
||||
2) 2
|
||||
3) 3
|
||||
#? ./errors4.sub: line 40: var: readonly variable
|
||||
./errors4.sub: line 45: break: x: numeric argument required
|
||||
1
|
||||
2
|
||||
./errors4.sub: line 20: var: readonly variable
|
||||
@@ -215,4 +238,4 @@ sh: line 1: unset: `a-b': not a valid identifier
|
||||
sh: line 1: /nosuchfile: No such file or directory
|
||||
sh: line 1: trap: SIGNOSIG: invalid signal specification
|
||||
after trap
|
||||
./errors.tests: line 316: `!!': not a valid identifier
|
||||
./errors.tests: line 333: `!!': not a valid identifier
|
||||
|
||||
@@ -34,6 +34,21 @@ unalias hoowah
|
||||
|
||||
# the iteration variable must be a valid identifier
|
||||
for 1 in a b c; do echo $1; done
|
||||
for f\1 in a b c ; do echo $f ; done
|
||||
|
||||
# in posix mode, it's a fatal error
|
||||
(set -o posix
|
||||
for invalid-name in a b c; do echo $1; done; echo after posix for)
|
||||
(set -o posix
|
||||
for f\1 in a b c ; do echo $f ; done; echo after posix for 2)
|
||||
|
||||
# same with select
|
||||
select 1 in a b c; do echo $REPLY; done
|
||||
select f\1 in a b c ; do echo $REPLY ; done
|
||||
select invalid-name in a b c; do echo $REPLY; done
|
||||
|
||||
(set -o posix ; select 1 in a b c; do echo $REPLY; done; echo after posix select)
|
||||
(set -o posix ; select f\1 in a b c ; do echo $REPLY ; done ; echo after posix select 2)
|
||||
|
||||
# try to rebind a read-only function
|
||||
func()
|
||||
@@ -271,6 +286,8 @@ kill -INT
|
||||
|
||||
# bad shell option names
|
||||
set -o trackall # bash is not ksh
|
||||
set -q # this is an error
|
||||
set -i # this is not allowed
|
||||
|
||||
# problem with versions through bash-4.2
|
||||
readonly xx=5
|
||||
|
||||
@@ -23,6 +23,22 @@ for num in 1 2 3 4 5; do
|
||||
done
|
||||
echo after readonly assignment
|
||||
|
||||
# can't have the variable in a for command be readonly
|
||||
for var in 1 2 3 4 5; do echo $var; done
|
||||
|
||||
# but in posix mode these are fatal errors
|
||||
(set -o posix
|
||||
for f in 1 2 3 4; do readonly f; done ; echo after for readonly assignment)
|
||||
|
||||
(set -o posix
|
||||
for var in 1 2 3 4; do echo $var; done; echo after posix for readonly variable)
|
||||
|
||||
# same with select
|
||||
select var in 1 2 3; do echo $REPLY; done <<<1
|
||||
|
||||
(set -o posix
|
||||
select var in 1 2 3; do echo $REPLY; done <<<1 ; echo after posix select readonly variable)
|
||||
|
||||
# non-numeric arguments to break are fatal errors for all non-interactive shells
|
||||
for f in 1 2 3 4 5
|
||||
do
|
||||
|
||||
+17
-1
@@ -125,6 +125,22 @@ a aa b bb
|
||||
.a .aa .b .bb a aa b bb
|
||||
.a .aa .b .bb
|
||||
. .. .a .aa .b .bb
|
||||
mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM
|
||||
|
||||
mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM
|
||||
mksyntax.dSYM mksyntax mksignames.o mksignames make_cmd.o mailcheck.o
|
||||
|
||||
mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM
|
||||
mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM
|
||||
|
||||
mksyntax mksignames make_cmd.o mailcheck.o mksignames.o mksyntax.dSYM
|
||||
mksyntax.dSYM mksignames.o mailcheck.o make_cmd.o mksignames mksyntax
|
||||
|
||||
mksyntax mksignames make_cmd.o mailcheck.o mksignames.o mksyntax.dSYM
|
||||
mksyntax.dSYM mksignames.o mailcheck.o make_cmd.o mksignames mksyntax
|
||||
|
||||
mksyntax mksignames make_cmd.o mailcheck.o mksignames.o mksyntax.dSYM
|
||||
mksyntax.dSYM mksignames.o mailcheck.o make_cmd.o mksignames mksyntax
|
||||
argv[1] = <a>
|
||||
argv[2] = <abc>
|
||||
argv[3] = <abd>
|
||||
@@ -139,7 +155,7 @@ argv[2] = <abc>
|
||||
argv[3] = <abd>
|
||||
argv[4] = <abe>
|
||||
tmp/l1 tmp/l2 tmp/*4 tmp/l3
|
||||
./glob.tests: line 66: no match: tmp/*4
|
||||
./glob.tests: line 67: no match: tmp/*4
|
||||
argv[1] = <bdir/>
|
||||
argv[1] = <*>
|
||||
argv[1] = <a*>
|
||||
|
||||
@@ -31,6 +31,7 @@ ${THIS_SH} ./glob7.sub
|
||||
${THIS_SH} ./glob8.sub
|
||||
${THIS_SH} ./glob9.sub
|
||||
${THIS_SH} ./glob10.sub
|
||||
${THIS_SH} ./glob11.sub
|
||||
|
||||
MYDIR=$PWD # save where we are
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# testing GLOBSORT
|
||||
LC_COLLATE=C
|
||||
LC_CTYPE=C
|
||||
LANG=C
|
||||
|
||||
: ${TMPDIR:=/tmp}
|
||||
|
||||
TDIR=$TMPDIR/glob-$$
|
||||
{ mkdir $TDIR && cd $TDIR; } || exit 1
|
||||
|
||||
# try to impose some kind of testable ordering
|
||||
echo 123 > mksyntax ; sleep 0.1
|
||||
echo 123456 > mksignames ; sleep 0.1
|
||||
echo 1234567879 > make_cmd.o ; sleep 0.1
|
||||
echo 123456789012 > mailcheck.o ; sleep 0.1
|
||||
echo 123456789012345 > mksignames.o ; sleep 0.1
|
||||
echo 123456789012345678 > mksyntax.dSYM ; sleep 0.1
|
||||
|
||||
echo m*
|
||||
GLOBSORT=nosort
|
||||
#echo m* # might have to take this one out
|
||||
unset GLOBSORT
|
||||
echo
|
||||
|
||||
GLOBSORT=
|
||||
echo m*
|
||||
GLOBSORT='-name'
|
||||
echo m*
|
||||
echo
|
||||
|
||||
GLOBSORT='+nonsense'
|
||||
echo m*
|
||||
GLOBSORT='-nonsense'
|
||||
echo m*
|
||||
echo
|
||||
|
||||
GLOBSORT='+atime'
|
||||
echo m*
|
||||
GLOBSORT='-atime'
|
||||
echo m*
|
||||
echo
|
||||
|
||||
GLOBSORT='+mtime'
|
||||
echo m*
|
||||
GLOBSORT='-mtime'
|
||||
echo m*
|
||||
echo
|
||||
|
||||
GLOBSORT=size
|
||||
echo m*
|
||||
GLOBSORT=-size
|
||||
echo m*
|
||||
|
||||
cd $OLDPWD
|
||||
rm -rf $TDIR
|
||||
+6
-1
@@ -17,14 +17,18 @@ hi\
|
||||
there
|
||||
EO\
|
||||
F
|
||||
line 1line 2
|
||||
hi
|
||||
hi
|
||||
nextEOF
|
||||
tab 1
|
||||
tab 2
|
||||
tab 3
|
||||
abc
|
||||
def ghi
|
||||
jkl mno
|
||||
echo "
|
||||
echo \"
|
||||
fff is a function
|
||||
fff ()
|
||||
{
|
||||
@@ -150,6 +154,7 @@ HERE
|
||||
done
|
||||
}
|
||||
comsub here-string
|
||||
./heredoc.tests: line 159: warning: here-document at line 157 delimited by end-of-file (wanted `EOF')
|
||||
./heredoc.tests: line 181: warning: here-document at line 178 delimited by end-of-file (wanted `')
|
||||
hi
|
||||
there
|
||||
''
|
||||
|
||||
+28
-6
@@ -80,6 +80,12 @@ F
|
||||
EOF
|
||||
true
|
||||
|
||||
# but unquoted here-documents remove backslash-newline
|
||||
cat <<EOF
|
||||
line 1\
|
||||
line 2
|
||||
EOF
|
||||
|
||||
# check that \newline is removed at start of here-doc
|
||||
cat << EO\
|
||||
F
|
||||
@@ -92,6 +98,12 @@ hi
|
||||
EO\
|
||||
F
|
||||
|
||||
# backslash-newline processing is performed before the check for the delimiter
|
||||
cat <<EOF
|
||||
next\
|
||||
EOF
|
||||
EOF
|
||||
|
||||
# check operation of tab removal in here documents
|
||||
cat <<- EOF
|
||||
tab 1
|
||||
@@ -100,16 +112,25 @@ cat <<- EOF
|
||||
EOF
|
||||
|
||||
# check appending of text to file from here document
|
||||
rm -f ${TMPDIR}/bash-zzz
|
||||
cat > ${TMPDIR}/bash-zzz << EOF
|
||||
rm -f ${TMPDIR}/bash-zzz-$$
|
||||
cat > ${TMPDIR}/bash-zzz-$$ << EOF
|
||||
abc
|
||||
EOF
|
||||
cat >> ${TMPDIR}/bash-zzz << EOF
|
||||
cat >> ${TMPDIR}/bash-zzz-$$ << EOF
|
||||
def ghi
|
||||
jkl mno
|
||||
EOF
|
||||
cat ${TMPDIR}/bash-zzz
|
||||
rm -f ${TMPDIR}/bash-zzz
|
||||
cat ${TMPDIR}/bash-zzz-$$
|
||||
rm -f ${TMPDIR}/bash-zzz-$$
|
||||
|
||||
# check behavior of double quotes and backslashes in here-documents
|
||||
cat <<EOF
|
||||
echo "
|
||||
EOF
|
||||
|
||||
cat <<EOF
|
||||
echo \"
|
||||
EOF
|
||||
|
||||
# make sure command printing puts the here-document as the last redirection
|
||||
# on the line, and the function export code preserves syntactic correctness
|
||||
@@ -154,6 +175,7 @@ echo $(
|
||||
# check that end of file delimits a here-document
|
||||
# THIS MUST BE LAST!
|
||||
|
||||
cat << EOF
|
||||
cat <<''
|
||||
hi
|
||||
there
|
||||
''
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
.: .: Is a directory
|
||||
bash: -c: option requires an argument
|
||||
bash: --badopt: invalid option
|
||||
bash [GNU long option] [option] ...
|
||||
bash [GNU long option] [option] script-file ...
|
||||
GNU long options:
|
||||
--debug
|
||||
--debugger
|
||||
--dump-po-strings
|
||||
--dump-strings
|
||||
--help
|
||||
--init-file
|
||||
--login
|
||||
--noediting
|
||||
--noprofile
|
||||
--norc
|
||||
--posix
|
||||
--pretty-print
|
||||
--rcfile
|
||||
--restricted
|
||||
--verbose
|
||||
--version
|
||||
Shell options:
|
||||
-ilrsD or -c command or -O shopt_option (invocation only)
|
||||
-abefhkmnptuvxBCEHPT or -o option
|
||||
bash: --initfile: invalid option
|
||||
bash [GNU long option] [option] ...
|
||||
bash [GNU long option] [option] script-file ...
|
||||
GNU long options:
|
||||
--debug
|
||||
--debugger
|
||||
--dump-po-strings
|
||||
--dump-strings
|
||||
--help
|
||||
--init-file
|
||||
--login
|
||||
--noediting
|
||||
--noprofile
|
||||
--norc
|
||||
--posix
|
||||
--pretty-print
|
||||
--rcfile
|
||||
--restricted
|
||||
--verbose
|
||||
--version
|
||||
Shell options:
|
||||
-ilrsD or -c command or -O shopt_option (invocation only)
|
||||
-abefhkmnptuvxBCEHPT or -o option
|
||||
bash: -q: invalid option
|
||||
bash [GNU long option] [option] ...
|
||||
bash [GNU long option] [option] script-file ...
|
||||
GNU long options:
|
||||
--debug
|
||||
--debugger
|
||||
--dump-po-strings
|
||||
--dump-strings
|
||||
--help
|
||||
--init-file
|
||||
--login
|
||||
--noediting
|
||||
--noprofile
|
||||
--norc
|
||||
--posix
|
||||
--pretty-print
|
||||
--rcfile
|
||||
--restricted
|
||||
--verbose
|
||||
--version
|
||||
Shell options:
|
||||
-ilrsD or -c command or -O shopt_option (invocation only)
|
||||
-abefhkmnptuvxBCEHPT or -o option
|
||||
this-bash
|
||||
$- for -c includes c
|
||||
a
|
||||
a
|
||||
bad-interp
|
||||
./invocation.tests: ./x23: nosuchfile: bad interpreter: No such file or directory
|
||||
@@ -0,0 +1,62 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
: ${THIS_SH:=./bash}
|
||||
|
||||
# invocation modes and errors
|
||||
|
||||
export BASH_ARGV0=this-bash
|
||||
|
||||
${THIS_SH} .
|
||||
|
||||
#${THIS_SH} --version -c 'exit 0' bash
|
||||
#${THIS_SH} --help -c 'exit 0' bash
|
||||
|
||||
${THIS_SH} -c |& sed 's|^.*/bash|bash|'
|
||||
|
||||
${THIS_SH} --badopt |& sed 's|^.*/bash|bash|'
|
||||
${THIS_SH} --initfile |& sed 's|^.*/bash|bash|'
|
||||
${THIS_SH} -q |& sed 's|^.*/bash|bash|'
|
||||
|
||||
${THIS_SH} -c 'echo $0'
|
||||
|
||||
{ ${THIS_SH} -c 'echo $-' bash | grep c >/dev/null; } && echo '$- for -c includes c'
|
||||
|
||||
: ${TMPDIR:=/tmp}
|
||||
TDIR=$TMPDIR/invocation-$$
|
||||
mkdir $TDIR || exit 1
|
||||
SAVEPWD=$PWD
|
||||
|
||||
# script that ends with a comment and no newline
|
||||
printf 'echo a # comment' > $TDIR/x23.in
|
||||
${THIS_SH} $TDIR/x23.in
|
||||
printf 'echo a' > $TDIR/x23.in
|
||||
${THIS_SH} $TDIR/x23.in
|
||||
rm -f $TDIR/x23.in
|
||||
|
||||
# script with invalid interpreter
|
||||
cat > $TDIR/x23 <<EOF
|
||||
#! nosuchfile
|
||||
echo bad-interp
|
||||
EOF
|
||||
chmod +x $TDIR/x23
|
||||
|
||||
# this is fine
|
||||
${THIS_SH} $TDIR/x23
|
||||
command cd -L $TDIR
|
||||
# but this results in a bad-interpreter error
|
||||
./x23
|
||||
|
||||
cd $SAVEPWD
|
||||
rm -rf $TDIR
|
||||
@@ -39,3 +39,7 @@ a
|
||||
real 0.00
|
||||
user 0.00
|
||||
sys 0.00
|
||||
real 0.00
|
||||
user 0.00
|
||||
sys 0.00
|
||||
4
|
||||
|
||||
@@ -54,3 +54,10 @@ echo $?
|
||||
echo $?
|
||||
|
||||
time -p -- echo a
|
||||
|
||||
time -- :
|
||||
|
||||
# this should print timing information
|
||||
. ./test-glue-functions
|
||||
|
||||
${THIS_SH} -c '{ time; echo after; }' |& wc -l | _cut_leading_spaces
|
||||
|
||||
@@ -72,6 +72,8 @@ string \
|
||||
string \
|
||||
string \
|
||||
string \}
|
||||
escape\
|
||||
escape\
|
||||
'weferfds'\''dsfsdf'
|
||||
'weferfdsdsfsdf'
|
||||
'weferfds'\''dsfsdf'
|
||||
|
||||
@@ -133,6 +133,13 @@ echo ${foo:-'string \'}
|
||||
echo "${foo:-string \\}"
|
||||
echo ${foo:-string \\\}}
|
||||
|
||||
: ${TMPDIR:=/tmp}
|
||||
|
||||
${THIS_SH} -c 'echo escape\'
|
||||
printf 'echo escape\' > $TMPDIR/quote-$$
|
||||
${THIS_SH} $TMPDIR/quote-$$
|
||||
rm -f $TMPDIR/quote-$$
|
||||
|
||||
${THIS_SH} ./quote1.sub
|
||||
${THIS_SH} ./quote2.sub
|
||||
${THIS_SH} ./quote3.sub
|
||||
|
||||
+6
-2
@@ -3,7 +3,11 @@ abc
|
||||
abc
|
||||
def
|
||||
def
|
||||
./redir.tests: line 44: $z: ambiguous redirect
|
||||
ghi
|
||||
./redir.tests: line 49: -1: ambiguous redirect
|
||||
./redir.tests: line 50: exec: -1: invalid option
|
||||
exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
|
||||
./redir.tests: line 55: $z: ambiguous redirect
|
||||
Point 1
|
||||
Point 2
|
||||
to a
|
||||
@@ -44,7 +48,7 @@ kl
|
||||
ab
|
||||
cd
|
||||
cd
|
||||
./redir.tests: line 170: redir1.*: No such file or directory
|
||||
./redir.tests: line 181: redir1.*: No such file or directory
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
+16
-5
@@ -24,20 +24,31 @@ cat /tmp/redir-test
|
||||
|
||||
set -o noclobber
|
||||
|
||||
#this should be an error
|
||||
#this should be an error, so it needs the same fixed filename
|
||||
echo def > /tmp/redir-test
|
||||
cat /tmp/redir-test
|
||||
|
||||
# but this should succeed
|
||||
echo def > /tmp/redir-test-2
|
||||
cat /tmp/redir-test-2
|
||||
echo def > $TMPDIR/redir-test-2
|
||||
cat $TMPDIR/redir-test-2
|
||||
|
||||
# and so should this
|
||||
echo def >| /tmp/redir-test
|
||||
cat /tmp/redir-test
|
||||
|
||||
# this should work as normal
|
||||
echo ghi >| $TMPDIR/redir-test-3
|
||||
cat $TMPDIR/redir-test-3
|
||||
|
||||
set +o noclobber
|
||||
rm /tmp/redir-test /tmp/redir-test-2
|
||||
rm -f /tmp/redir-test
|
||||
rm -f $TMPDIR/redir-test-2 $TMPDIR/redir-test-3
|
||||
|
||||
# these are errors
|
||||
fd=-1
|
||||
exec <&$fd
|
||||
exec $fd</dev/null
|
||||
unset -v fd
|
||||
|
||||
# this should be an error
|
||||
z="a b"
|
||||
@@ -71,7 +82,7 @@ cat $TMPDIR/bash-c
|
||||
echo "Point 5"
|
||||
|
||||
# clean up before running scripts
|
||||
exec 4>&- 5>&- 6<&-
|
||||
exec 4>&- 5>&- 6<&$unset- # ksh93 quirk with unset variable
|
||||
|
||||
rm -f $TMPDIR/bash-a $TMPDIR/bash-b $TMPDIR/bash-c
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
${THIS_SH} ./invocation.tests 2>&1 | grep -v '^expect' > ${BASH_TSTOUT}
|
||||
diff ${BASH_TSTOUT} invocation.right && rm -f ${BASH_TSTOUT}
|
||||
@@ -22,6 +22,8 @@ until succeeded: 4
|
||||
if succeeded
|
||||
AND list succeeded
|
||||
OR list succeeded
|
||||
00 01 02 03 04 05 06 07 08 09
|
||||
00 01 02 03 04 05 06 07 08 09
|
||||
! succeeded
|
||||
eval succeeded
|
||||
! eval succeeded -- 1
|
||||
|
||||
@@ -80,6 +80,19 @@ echo AND list succeeded
|
||||
|
||||
false || echo OR list succeeded
|
||||
|
||||
# more compound commands containing failing commands
|
||||
for (( f=0; f<10; f++ )); do
|
||||
printf '%.2d ' $f
|
||||
false
|
||||
done && echo done
|
||||
echo
|
||||
|
||||
for f in {0..9}; do
|
||||
printf '%.2d ' $f
|
||||
false
|
||||
done && echo done
|
||||
echo
|
||||
|
||||
! false
|
||||
echo ! succeeded
|
||||
|
||||
|
||||
@@ -32,4 +32,7 @@ time ${THIS_SH} /dev/null
|
||||
printf "\ntimes:\n"
|
||||
times
|
||||
|
||||
printf "\ntime standalone:\n"
|
||||
{ time ; echo after; } |& wc -l
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -105,6 +105,12 @@ fn
|
||||
after 1
|
||||
fn
|
||||
after 2
|
||||
before
|
||||
after
|
||||
CHLD
|
||||
CHLD
|
||||
CHLD
|
||||
CHLD
|
||||
caught a child death
|
||||
caught a child death
|
||||
caught a child death
|
||||
|
||||
@@ -93,6 +93,10 @@ ${THIS_SH} ./trap6.sub
|
||||
# eval and ERR trap
|
||||
${THIS_SH} ./trap7.sub
|
||||
|
||||
# SIGCHLD traps
|
||||
${THIS_SH} ./trap8.sub
|
||||
|
||||
|
||||
#
|
||||
# show that setting a trap on SIGCHLD is not disastrous.
|
||||
#
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# tests for traps on SIGCHLD and async commands
|
||||
|
||||
set -m
|
||||
|
||||
trap 'echo CHLD' SIGCHLD
|
||||
|
||||
{ echo before ; : ; echo after; } &
|
||||
wait
|
||||
|
||||
sleep 1 &
|
||||
sleep 1 &
|
||||
|
||||
sleep 1
|
||||
wait
|
||||
+5
-1
@@ -11,6 +11,8 @@ bar ()
|
||||
./vredir.tests: line 19: v: readonly variable
|
||||
./vredir.tests: line 19: v: cannot assign fd to variable
|
||||
42
|
||||
./vredir.tests: line 38: v: readonly variable
|
||||
./vredir.tests: line 38: v: cannot assign fd to variable
|
||||
bar is a function
|
||||
bar ()
|
||||
{
|
||||
@@ -98,4 +100,6 @@ swizzle ()
|
||||
exec {stdin}<&${fd[0]}-;
|
||||
exec {stdout}>&${fd[1]}-
|
||||
}
|
||||
./vredir8.sub: line 12: $fd: Bad file descriptor
|
||||
redir 2
|
||||
./vredir8.sub: line 33: $fd: Bad file descriptor
|
||||
./vredir8.sub: line 38: $fd: Bad file descriptor
|
||||
|
||||
@@ -32,8 +32,10 @@ rm -f $TMPFILE
|
||||
type bar
|
||||
exec {v}>&-
|
||||
|
||||
# errors
|
||||
readonly v=42
|
||||
bar
|
||||
exec {v}>&1
|
||||
|
||||
echo foo 1 2>&1 >&$v | { grep -q '\$v: Bad' || echo 'bad foo 1'; }
|
||||
echo foo 2 2>&1 >&$v | { grep -q '\$v: Bad' || echo 'bad foo 2'; }
|
||||
|
||||
+28
-1
@@ -1,13 +1,40 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# test varredir_close
|
||||
|
||||
# these should work fine
|
||||
|
||||
: {fd}<>/dev/null
|
||||
|
||||
echo redir 1 >&$fd
|
||||
exec {fd}>&-
|
||||
|
||||
: {fd}>&1
|
||||
echo redir 2 >&$fd
|
||||
exec {fd}>&-
|
||||
|
||||
shopt -s varredir_close
|
||||
|
||||
: {fd}<>/dev/tty
|
||||
|
||||
echo redir 2 >&$fd
|
||||
# these should fail with Bad file descriptor errors
|
||||
echo redir 3 >&$fd
|
||||
exec {fd}>&-
|
||||
unset fd
|
||||
|
||||
: {fd}>&1
|
||||
echo redir 4 >&$fd
|
||||
unset fd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user