home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / alpha / PARTITIONS / USR_GZ / usr / lib / trn / filexp next >
Encoding:
Text File  |  1995-05-14  |  675 b   |  39 lines

  1. #!/bin/sh
  2. sed=/usr/bin/sed
  3. expr=/usr/bin/expr
  4. basename=/usr/bin/basename
  5. test=test
  6. : expand filename
  7. case "$1" in
  8.  ~/*|~)
  9.     echo $1 | $sed "s|~|${HOME-$LOGDIR}|"
  10.     ;;
  11.  ~*)
  12.     if $test -f /bin/csh; then
  13.         /bin/csh -f -c "glob $1"
  14.         failed=$?
  15.         echo ""
  16.         exit $failed
  17.     else
  18.         name=`$expr x$1 : '..\([^/]*\)'`
  19.         dir=`$sed -n -e "/^${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e p -e q -e '}' </etc/passwd`
  20.         if $test ! -d "$dir"; then
  21.             me=`$basename $0`
  22.             echo "$me: can't locate home directory for: $name" >&2
  23.             exit 1
  24.         fi
  25.         case "$1" in
  26.         */*)
  27.             echo $dir/`$expr x$1 : '..[^/]*/\(.*\)'`
  28.             ;;
  29.         *)
  30.             echo $dir
  31.             ;;
  32.         esac
  33.     fi
  34.     ;;
  35. *)
  36.     echo $1
  37.     ;;
  38. esac
  39.