function err_exit
{
print -u2 -n "\t"
print -u2 -r $Command: "$@"
let Errors+=1
}
alias err_exit='err_exit $LINENO'
function home {
typeset IFS=: pwd=/etc/passwd
set -o noglob
if [[ -f $pwd ]] && grep -c "^$1:" $pwd > /dev/null
then set -- $(grep "^$1:" $pwd)
print -r -- "$6"
else print .
fi
}
Command=${0integer Errors=0
OLDPWD=/bin
if [[ ~ != $HOME ]]
then err_exit '~' not $HOME
fi
x=~
if [[ $x != $HOME ]]
then err_exit x=~ not $HOME
fi
x=x:~
if [[ $x != x:$HOME ]]
then err_exit x=x:~ not x:$HOME
fi
if [[ ~+ != $PWD ]]
then err_exit '~' not $PWD
fi
x=~+
if [[ $x != $PWD ]]
then err_exit x=~+ not $PWD
fi
if [[ ~- != $OLDPWD ]]
then err_exit '~' not $PWD
fi
x=~-
if [[ $x != $OLDPWD ]]
then err_exit x=~- not $OLDPWD
fi
for u in root Administrator
do h=$(home $u)
if [[ $h != . ]]
then [[ ~$u -ef $h ]] || err_exit "~$u not $h"
x=~$u
[[ $x -ef $h ]] || "x=~$u not $h"
break
fi
done
x=~%%
if [[ $x != '~%%' ]]
then err_exit 'x='~%%' not '~%%
fi
x=~:~
if [[ $x != "$HOME:$HOME" ]]
then err_exit x=~:~ not $HOME:$HOME
fi
HOME=/
[[ ~ == / ]] || err_exit '~ should be /'
[[ ~/foo == /foo ]] || err_exit '~/foo should be /foo when ~==/'
exit $((Errors))