1 ########################################################################
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 #
9 # A copy of the License is available at #
10 # http://www.opensource.org/licenses/cpl1.0.txt #
11 # (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
13 # Information and Software Systems Research #
17 # David Korn <dgk@research.att.com> #
19 ########################################################################
23 print
-u2 -r $Command: "$@"
26 alias err_exit
='err_exit $LINENO'
31 tmp
=$
(mktemp
-dt) ||
{ err_exit mktemp
-dt failed
; exit 1; }
32 trap "cd /; rm -rf $tmp" EXIT
36 typeset IFS
=: pwd=/etc
/passwd
38 if [[ -f $pwd ]] && grep -c "^$1:" $pwd > /dev
/null
39 then set -- $
(grep "^$1:" $pwd)
47 then err_exit
'~' not
$HOME
51 then err_exit x
=~ not
$HOME
54 if [[ $x != x
:$HOME ]]
55 then err_exit x
=x
:~ not x
:$HOME
58 then err_exit
'~' not
$PWD
62 then err_exit x
=~
+ not
$PWD
64 if [[ ~
- != $OLDPWD ]]
65 then err_exit
'~' not
$PWD
68 if [[ $x != $OLDPWD ]]
69 then err_exit x
=~
- not
$OLDPWD
71 for u
in root Administrator
74 then [[ ~
$u -ef $h ]] || err_exit
"~$u not $h"
76 [[ $x -ef $h ]] || x
="~$u not $h"
81 if [[ $x != '~g.r.emlin' ]]
82 then err_exit
"x=~g.r.emlin failed -- expected '~g.r.emlin', got '$x'"
85 if [[ $x != "$HOME:$HOME" ]]
86 then err_exit
"x=~:~ failed, expected '$HOME:$HOME', got '$x'"
89 [[ ~
== / ]] || err_exit
'~ should be /'
90 [[ ~
/foo
== /foo
]] || err_exit
'~/foo should be /foo when ~==/'
91 print $
'print ~+\n[[ $1 ]] && $0' > $tmp/tilde
94 [[ $
($tmp/tilde foo
) == "$PWD$nl$PWD" ]] 2> /dev
/null || err_exit
'tilde fails inside a script run by name'