]>
Commit | Line | Data |
---|---|---|
8868edaf CR |
1 | # This program is free software: you can redistribute it and/or modify |
2 | # it under the terms of the GNU General Public License as published by | |
3 | # the Free Software Foundation, either version 3 of the License, or | |
4 | # (at your option) any later version. | |
5 | # | |
6 | # This program is distributed in the hope that it will be useful, | |
7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9 | # GNU General Public License for more details. | |
10 | # | |
11 | # You should have received a copy of the GNU General Public License | |
12 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
13 | # | |
d233b485 | 14 | wdir=$PWD |
d166f048 JA |
15 | # this is needed because posix mode restricts tilde expansion to assignment |
16 | # statements preceding a command, instead of the default of expanding all | |
17 | # assignment statements on the line (e.g., after `export'). Without this, | |
18 | # the next-to-last test fails | |
19 | set +o posix | |
20 | ||
726f6388 | 21 | HOME=/usr/xyz |
ccc6cda3 | 22 | SHELL=~/bash |
726f6388 | 23 | echo ~ch\et |
ccc6cda3 | 24 | echo ~/"foo" |
726f6388 JA |
25 | echo "~chet"/"foo" |
26 | echo \~chet/"foo" | |
27 | echo \~chet/bar | |
28 | echo ~\chet/bar | |
29 | echo ~chet""/bar | |
30 | echo ":~chet/" | |
31 | echo abcd~chet | |
32 | echo "SHELL=~/bash" | |
ccc6cda3 | 33 | echo $SHELL |
726f6388 | 34 | echo abcd:~chet |
ccc6cda3 JA |
35 | path=/usr/ucb:/bin:~/bin:~/tmp/bin:/usr/bin |
36 | echo $path | |
37 | ||
38 | cd /usr | |
39 | cd /tmp | |
40 | echo ~- | |
41 | echo ~+ | |
42 | ||
43 | XPATH=/bin:/usr/bin:. | |
44 | ||
45 | # yes tilde expansion | |
46 | PPATH=$XPATH:~/bin | |
47 | echo "$PPATH" | |
48 | ||
49 | # no tilde expansion | |
50 | PPATH="$XPATH:~/bin" | |
51 | echo "$PPATH" | |
52 | ||
53 | # yes tilde expansion | |
54 | export PPATH=$XPATH:~/bin | |
55 | echo "$PPATH" | |
d166f048 JA |
56 | declare -x PPATH=$XPATH:~/bin |
57 | echo "$PPATH" | |
ccc6cda3 JA |
58 | |
59 | # no tilde expansion | |
60 | export PPATH="$XPATH:~/bin" | |
61 | echo "$PPATH" | |
d166f048 JA |
62 | declare -x PPATH="$XPATH:~/bin" |
63 | echo "$PPATH" | |
64 | ||
ac50fbac CR |
65 | printf "%q\n" '~' |
66 | ||
d166f048 JA |
67 | # more tests of tilde expansion when executing case commands |
68 | case ~ in | |
69 | $HOME) echo ok 1;; | |
70 | *) echo bad 1 ;; | |
71 | esac | |
72 | ||
73 | case ~ in | |
74 | ~) echo ok 2 ;; | |
75 | \~) echo bad 2a ;; | |
76 | *) echo bad 2b ;; | |
77 | esac | |
78 | ||
79 | case $unset in | |
80 | "") echo ok 3 ;; | |
81 | *) echo bad 3 ;; | |
82 | esac | |
0628567a JA |
83 | |
84 | USER=root # should exist just about everywhere | |
85 | echo ~$USER | |
d233b485 CR |
86 | |
87 | cd "$wdir" | |
8868edaf | 88 | |
4491c030 CR |
89 | # this test is incomplete; should also test assignment statements (tilde3.sub) |
90 | echo foo=bar:~ | |
91 | set -o posix | |
8868edaf | 92 | echo foo=bar:~ |
8868edaf | 93 | |
d233b485 | 94 | exit 0 |