i-bash/tests/tilde.tests

72 lines
1.2 KiB
Text
Raw Permalink Normal View History

1997-06-05 14:59:13 +00:00
# this is needed because posix mode restricts tilde expansion to assignment
# statements preceding a command, instead of the default of expanding all
# assignment statements on the line (e.g., after `export'). Without this,
# the next-to-last test fails
set +o posix
1996-08-26 18:22:31 +00:00
HOME=/usr/xyz
1996-12-23 17:02:34 +00:00
SHELL=~/bash
1996-08-26 18:22:31 +00:00
echo ~ch\et
1996-12-23 17:02:34 +00:00
echo ~/"foo"
1996-08-26 18:22:31 +00:00
echo "~chet"/"foo"
echo \~chet/"foo"
echo \~chet/bar
echo ~\chet/bar
echo ~chet""/bar
echo ":~chet/"
echo abcd~chet
echo "SHELL=~/bash"
1996-12-23 17:02:34 +00:00
echo $SHELL
1996-08-26 18:22:31 +00:00
echo abcd:~chet
1996-12-23 17:02:34 +00:00
path=/usr/ucb:/bin:~/bin:~/tmp/bin:/usr/bin
echo $path
cd /usr
cd /tmp
echo ~-
echo ~+
XPATH=/bin:/usr/bin:.
# yes tilde expansion
PPATH=$XPATH:~/bin
echo "$PPATH"
# no tilde expansion
PPATH="$XPATH:~/bin"
echo "$PPATH"
# yes tilde expansion
export PPATH=$XPATH:~/bin
echo "$PPATH"
1997-06-05 14:59:13 +00:00
declare -x PPATH=$XPATH:~/bin
echo "$PPATH"
1996-12-23 17:02:34 +00:00
# no tilde expansion
export PPATH="$XPATH:~/bin"
echo "$PPATH"
1997-06-05 14:59:13 +00:00
declare -x PPATH="$XPATH:~/bin"
echo "$PPATH"
printf "%q\n" '~'
1997-06-05 14:59:13 +00:00
# more tests of tilde expansion when executing case commands
case ~ in
$HOME) echo ok 1;;
*) echo bad 1 ;;
esac
case ~ in
~) echo ok 2 ;;
\~) echo bad 2a ;;
*) echo bad 2b ;;
esac
case $unset in
"") echo ok 3 ;;
*) echo bad 3 ;;
esac
2006-10-10 14:15:34 +00:00
USER=root # should exist just about everywhere
echo ~$USER