2009-03-29 00:25:34 +05:30
|
|
|
# do all of these in subshells since it's supposed to error out
|
|
|
|
|
|
|
|
# first try some invalid patterns
|
2009-06-01 23:39:09 +05:30
|
|
|
#"$THIS_SH" -c 'echo ${?}' -- this is valid as it's the same as $?
|
2009-04-01 03:44:32 +05:30
|
|
|
"$THIS_SH" -c 'echo ${:?}'
|
2009-03-29 00:25:34 +05:30
|
|
|
|
|
|
|
# then some funky ones
|
2010-05-21 21:24:46 +05:30
|
|
|
# note: bash prints 1 - treats it as "length of $#"? We print 0
|
2009-04-01 03:44:32 +05:30
|
|
|
"$THIS_SH" -c 'echo ${#?}'
|
2010-05-21 21:24:46 +05:30
|
|
|
# bash prints 0
|
2009-04-01 03:44:32 +05:30
|
|
|
"$THIS_SH" -c 'echo ${#:?}'
|
2009-03-29 00:25:34 +05:30
|
|
|
|
|
|
|
# now some valid ones
|
2010-05-21 21:24:46 +05:30
|
|
|
export msg_unset="unset!"
|
|
|
|
export msg_null_or_unset="null or unset!"
|
|
|
|
|
|
|
|
echo ====
|
2009-04-01 03:44:32 +05:30
|
|
|
"$THIS_SH" -c 'set --; echo _$1'
|
|
|
|
"$THIS_SH" -c 'set --; echo _${1?}'
|
|
|
|
"$THIS_SH" -c 'set --; echo _${1:?}'
|
2009-04-10 00:46:15 +05:30
|
|
|
"$THIS_SH" -c 'set --; echo _${1?message1}'
|
|
|
|
"$THIS_SH" -c 'set --; echo _${1:?message1}'
|
2010-05-21 21:24:46 +05:30
|
|
|
"$THIS_SH" -c 'set --; echo _${1?$msg_unset}'
|
|
|
|
"$THIS_SH" -c 'set --; echo _${1:?$msg_null_or_unset}'
|
2009-03-29 00:25:34 +05:30
|
|
|
|
2010-05-21 21:24:46 +05:30
|
|
|
echo ====
|
2009-04-01 03:44:32 +05:30
|
|
|
"$THIS_SH" -c 'set -- aaaa; echo _$1'
|
|
|
|
"$THIS_SH" -c 'set -- aaaa; echo _${1?}'
|
|
|
|
"$THIS_SH" -c 'set -- aaaa; echo _${1:?}'
|
|
|
|
"$THIS_SH" -c 'set -- aaaa; echo _${1?word}'
|
|
|
|
"$THIS_SH" -c 'set -- aaaa; echo _${1:?word}'
|
2010-05-21 21:24:46 +05:30
|
|
|
"$THIS_SH" -c 'set -- aaaa; echo _${1?$msg_unset}'
|
|
|
|
"$THIS_SH" -c 'set -- aaaa; echo _${1:?$msg_null_or_unset}'
|
2009-03-29 00:25:34 +05:30
|
|
|
|
2010-05-21 21:24:46 +05:30
|
|
|
echo ====
|
2009-04-01 03:44:32 +05:30
|
|
|
"$THIS_SH" -c 'unset f; echo _$f'
|
|
|
|
"$THIS_SH" -c 'unset f; echo _${f?}'
|
|
|
|
"$THIS_SH" -c 'unset f; echo _${f:?}'
|
2009-04-10 00:46:15 +05:30
|
|
|
"$THIS_SH" -c 'unset f; echo _${f?message3}'
|
|
|
|
"$THIS_SH" -c 'unset f; echo _${f:?message3}'
|
2010-05-21 21:24:46 +05:30
|
|
|
"$THIS_SH" -c 'unset f; echo _${f?$msg_unset}'
|
|
|
|
"$THIS_SH" -c 'unset f; echo _${f:?$msg_null_or_unset}'
|
2009-03-29 00:25:34 +05:30
|
|
|
|
2010-05-21 21:24:46 +05:30
|
|
|
echo ====
|
2009-04-01 03:44:32 +05:30
|
|
|
"$THIS_SH" -c 'f=; echo _$f'
|
|
|
|
"$THIS_SH" -c 'f=; echo _${f?}'
|
|
|
|
"$THIS_SH" -c 'f=; echo _${f:?}'
|
|
|
|
"$THIS_SH" -c 'f=; echo _${f?word}'
|
2009-04-10 00:46:15 +05:30
|
|
|
"$THIS_SH" -c 'f=; echo _${f:?message4}'
|
2010-05-21 21:24:46 +05:30
|
|
|
"$THIS_SH" -c 'f=; echo _${f?$msg_unset}'
|
|
|
|
"$THIS_SH" -c 'f=; echo _${f:?$msg_null_or_unset}'
|
2009-03-29 00:25:34 +05:30
|
|
|
|
2010-05-21 21:24:46 +05:30
|
|
|
echo ====
|
2009-04-01 03:44:32 +05:30
|
|
|
"$THIS_SH" -c 'f=fff; echo _$f'
|
|
|
|
"$THIS_SH" -c 'f=fff; echo _${f?}'
|
|
|
|
"$THIS_SH" -c 'f=fff; echo _${f:?}'
|
|
|
|
"$THIS_SH" -c 'f=fff; echo _${f?word}'
|
|
|
|
"$THIS_SH" -c 'f=fff; echo _${f:?word}'
|
2010-05-21 21:24:46 +05:30
|
|
|
"$THIS_SH" -c 'f=fff; echo _${f?$msg_unset}'
|
|
|
|
"$THIS_SH" -c 'f=fff; echo _${f:?$msg_null_or_unset}'
|