# Make sure expansion doesn't use assignment statements preceding a builtin
A=ZVAR echo $A
-PATH=/bin:/usr/bin:/usr/local/bin:.
+XPATH=/bin:/usr/bin:/usr/local/bin:.
func2()
{
local z=yy
- local -a avar=( ${PATH//: } )
+ local -a avar=( ${XPATH//: } )
echo ${avar[@]}
local
}
ivar=42
declare -p ivar
+# make sure set [-+]o ignoreeof and $IGNOREEOF are reflected
+unset IGNOREEOF
+set +o ignoreeof
+set -o ignoreeof
+if [ "$IGNOREEOF" -ne 10 ]; then
+ echo "./varenv.sh: set -o ignoreeof is not reflected in IGNOREEOF" >&2
+fi
+unset IGNOREEOF
+set +o ignoreeof
+
+# older versions of bash used to not reset RANDOM in subshells correctly
+[[ $RANDOM -eq $(echo $RANDOM) ]] && echo "RANDOM: problem with subshells"
+
# make sure that shopt -o is reflected in $SHELLOPTS
# first, get rid of things that might be set automatically via shell
# variables
set +o posix
set +o ignoreeof
+set +o monitor
echo $-
echo ${SHELLOPTS}
shopt -so physical
echo $-
echo ${SHELLOPTS}
+
+# and make sure it is readonly
+readonly -p | grep SHELLOPTS
+
+# This was an error in bash versions prior to bash-2.04. The `set -a'
+# should cause the assignment statement that's an argument to typeset
+# to create an exported variable
+unset FOOFOO
+FOOFOO=bar
+set -a
+typeset FOOFOO=abcde
+
+printenv FOOFOO
+
+# test out export behavior of variable assignments preceding builtins and
+# functions
+$THIS_SH ./varenv1.sub
+
+# more tests; bugs in bash up to version 2.05a
+$THIS_SH ./varenv2.sub
+
+# make sure variable scoping is done right
+tt() { typeset a=b;echo a=$a; };a=z;echo a=$a;tt;echo a=$a