]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/bin/sh/expansion/tilde1.0
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / bin / sh / expansion / tilde1.0
1 # $FreeBSD$
2
3 HOME=/tmp
4 roothome=~root
5 if [ "$roothome" = "~root" ]; then
6         echo "~root is not expanded!"
7         exit 2
8 fi
9
10 testcase() {
11         code="$1"
12         expected="$2"
13         oIFS="$IFS"
14         eval "$code"
15         IFS='|'
16         result="$#|$*"
17         IFS="$oIFS"
18         if [ "x$result" = "x$expected" ]; then
19                 ok=x$ok
20         else
21                 failures=x$failures
22                 echo "For $code, expected $expected actual $result"
23         fi
24 }
25
26 testcase 'set -- ~'                             '1|/tmp'
27 testcase 'set -- ~/foo'                         '1|/tmp/foo'
28 testcase 'set -- x~'                            '1|x~'
29 testcase 'set -- ~root'                         "1|$roothome"
30 h=~
31 testcase 'set -- "$h"'                          '1|/tmp'
32 ooIFS=$IFS
33 IFS=m
34 testcase 'set -- ~'                             '1|/tmp'
35 testcase 'set -- ~/foo'                         '1|/tmp/foo'
36 testcase 'set -- $h'                            '2|/t|p'
37 IFS=$ooIFS
38 t=\~
39 testcase 'set -- $t'                            '1|~'
40 r=$(cat <<EOF
41 ~
42 EOF
43 )
44 testcase 'set -- $r'                            '1|~'
45 r=$(cat <<EOF
46 ${t+~}
47 EOF
48 )
49 testcase 'set -- $r'                            '1|~'
50 r=$(cat <<EOF
51 ${t+~/.}
52 EOF
53 )
54 testcase 'set -- $r'                            '1|~/.'
55
56 test "x$failures" = x