sd: remove 'ssd' driver support
[unleashed/tickless.git] / usr / src / lib / libshell / common / tests / tilde.sh
blobef5dc5c364a261e8ec6bb219ccd314d0264f46a8
1 ########################################################################
2 # #
3 # This software is part of the ast package #
4 # Copyright (c) 1982-2010 AT&T Intellectual Property #
5 # and is licensed under the #
6 # Common Public License, Version 1.0 #
7 # by AT&T Intellectual Property #
8 # #
9 # A copy of the License is available at #
10 # http://www.opensource.org/licenses/cpl1.0.txt #
11 # (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
12 # #
13 # Information and Software Systems Research #
14 # AT&T Research #
15 # Florham Park NJ #
16 # #
17 # David Korn <dgk@research.att.com> #
18 # #
19 ########################################################################
20 function err_exit
22 print -u2 -n "\t"
23 print -u2 -r $Command: "$@"
24 let Errors+=1
26 alias err_exit='err_exit $LINENO'
28 Command=${0##*/}
29 integer Errors=0
31 tmp=$(mktemp -dt) || { err_exit mktemp -dt failed; exit 1; }
32 trap "cd /; rm -rf $tmp" EXIT
34 function home # id
36 typeset IFS=: pwd=/etc/passwd
37 set -o noglob
38 if [[ -f $pwd ]] && grep -c "^$1:" $pwd > /dev/null
39 then set -- $(grep "^$1:" $pwd)
40 print -r -- "$6"
41 else print .
45 OLDPWD=/bin
46 if [[ ~ != $HOME ]]
47 then err_exit '~' not $HOME
49 x=~
50 if [[ $x != $HOME ]]
51 then err_exit x=~ not $HOME
53 x=x:~
54 if [[ $x != x:$HOME ]]
55 then err_exit x=x:~ not x:$HOME
57 if [[ ~+ != $PWD ]]
58 then err_exit '~' not $PWD
60 x=~+
61 if [[ $x != $PWD ]]
62 then err_exit x=~+ not $PWD
64 if [[ ~- != $OLDPWD ]]
65 then err_exit '~' not $PWD
67 x=~-
68 if [[ $x != $OLDPWD ]]
69 then err_exit x=~- not $OLDPWD
71 for u in root Administrator
72 do h=$(home $u)
73 if [[ $h != . ]]
74 then [[ ~$u -ef $h ]] || err_exit "~$u not $h"
75 x=~$u
76 [[ $x -ef $h ]] || x="~$u not $h"
77 break
79 done
80 x=~g.r.emlin
81 if [[ $x != '~g.r.emlin' ]]
82 then err_exit "x=~g.r.emlin failed -- expected '~g.r.emlin', got '$x'"
84 x=~:~
85 if [[ $x != "$HOME:$HOME" ]]
86 then err_exit "x=~:~ failed, expected '$HOME:$HOME', got '$x'"
88 HOME=/
89 [[ ~ == / ]] || err_exit '~ should be /'
90 [[ ~/foo == /foo ]] || err_exit '~/foo should be /foo when ~==/'
91 print $'print ~+\n[[ $1 ]] && $0' > $tmp/tilde
92 chmod +x $tmp/tilde
93 nl=$'\n'
94 [[ $($tmp/tilde foo) == "$PWD$nl$PWD" ]] 2> /dev/null || err_exit 'tilde fails inside a script run by name'
95 exit $((Errors))