f5f5309023d5bc185a08e9fbded6423aa04caad0
[platform/upstream/bash.git] / tests / tilde-tests
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
5 set +o posix
6
7 HOME=/usr/xyz
8 SHELL=~/bash
9 echo ~ch\et
10 echo ~/"foo"
11 echo "~chet"/"foo"
12 echo \~chet/"foo"
13 echo \~chet/bar
14 echo ~\chet/bar
15 echo ~chet""/bar
16 echo ":~chet/"
17 echo abcd~chet
18 echo "SHELL=~/bash"
19 echo $SHELL
20 echo abcd:~chet
21 path=/usr/ucb:/bin:~/bin:~/tmp/bin:/usr/bin
22 echo $path
23
24 cd /usr
25 cd /tmp
26 echo ~-
27 echo ~+
28
29 XPATH=/bin:/usr/bin:.
30
31 # yes tilde expansion
32 PPATH=$XPATH:~/bin
33 echo "$PPATH"
34
35 # no tilde expansion
36 PPATH="$XPATH:~/bin"
37 echo "$PPATH"
38
39 # yes tilde expansion
40 export PPATH=$XPATH:~/bin
41 echo "$PPATH"
42 declare -x PPATH=$XPATH:~/bin
43 echo "$PPATH"
44
45 # no tilde expansion
46 export PPATH="$XPATH:~/bin"
47 echo "$PPATH"
48 declare -x PPATH="$XPATH:~/bin"
49 echo "$PPATH"
50
51 # more tests of tilde expansion when executing case commands
52 case ~ in
53 $HOME)  echo ok 1;;
54 *) echo bad 1 ;;
55 esac
56
57 case ~ in
58 ~)      echo ok 2 ;;
59 \~)     echo bad 2a ;;
60 *)      echo bad 2b ;;
61 esac
62
63 case $unset in
64 "")     echo ok 3 ;;
65 *)      echo bad 3 ;;
66 esac