]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/tilde.tests
Bash-4.2 patch 14
[thirdparty/bash.git] / tests / tilde.tests
CommitLineData
d166f048
JA
1# this is needed because posix mode restricts tilde expansion to assignment
2# statements preceding a command, instead of the default of expanding all
3# assignment statements on the line (e.g., after `export'). Without this,
4# the next-to-last test fails
5set +o posix
6
726f6388 7HOME=/usr/xyz
ccc6cda3 8SHELL=~/bash
726f6388 9echo ~ch\et
ccc6cda3 10echo ~/"foo"
726f6388
JA
11echo "~chet"/"foo"
12echo \~chet/"foo"
13echo \~chet/bar
14echo ~\chet/bar
15echo ~chet""/bar
16echo ":~chet/"
17echo abcd~chet
18echo "SHELL=~/bash"
ccc6cda3 19echo $SHELL
726f6388 20echo abcd:~chet
ccc6cda3
JA
21path=/usr/ucb:/bin:~/bin:~/tmp/bin:/usr/bin
22echo $path
23
24cd /usr
25cd /tmp
26echo ~-
27echo ~+
28
29XPATH=/bin:/usr/bin:.
30
31# yes tilde expansion
32PPATH=$XPATH:~/bin
33echo "$PPATH"
34
35# no tilde expansion
36PPATH="$XPATH:~/bin"
37echo "$PPATH"
38
39# yes tilde expansion
40export PPATH=$XPATH:~/bin
41echo "$PPATH"
d166f048
JA
42declare -x PPATH=$XPATH:~/bin
43echo "$PPATH"
ccc6cda3
JA
44
45# no tilde expansion
46export PPATH="$XPATH:~/bin"
47echo "$PPATH"
d166f048
JA
48declare -x PPATH="$XPATH:~/bin"
49echo "$PPATH"
50
51# more tests of tilde expansion when executing case commands
52case ~ in
53$HOME) echo ok 1;;
54*) echo bad 1 ;;
55esac
56
57case ~ in
58~) echo ok 2 ;;
59\~) echo bad 2a ;;
60*) echo bad 2b ;;
61esac
62
63case $unset in
64"") echo ok 3 ;;
65*) echo bad 3 ;;
66esac
0628567a
JA
67
68USER=root # should exist just about everywhere
69echo ~$USER