home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- : expand filename
- case $1 in
- ~/*|~)
- /bin/echo $1 | /bin/sed "s|~|${HOME-$LOGDIR}|"
- ;;
- ~*)
- if /bin/test -f /bin/csh; then
- /bin/csh -f -c "glob $1"
- /bin/echo ""
- else
- name=`/bin/expr x$1 : '..\([^/]*\)'`
- if /bin/test "" != ""; then
- dir=` $name passwd 2>/dev/null | /bin/sed "s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"'`
- elif /bin/test "" != ""; then
- dir=` passwd / | /bin/sed -n -e "/^${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e p -e q -e '}'`
- fi
- if /bin/test "$dir" = ""; then
- dir=`/bin/sed </etc/passwd -n -e "/^${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e p -e q -e '}'`
- fi
- if /bin/test ! -d "$dir"; then
- me=`basename $0`
- /bin/echo "$me: can't locate home directory for: $name" >&2
- exit 1
- fi
- case $1 in
- */*)
- /bin/echo $dir/`/bin/expr x$1 : '..[^/]*/\(.*\)'`
- ;;
- *)
- /bin/echo $dir
- ;;
- esac
- fi
- ;;
- *)
- /bin/echo $1
- ;;
- esac
-