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