BSD 4_4_Lite2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 8 Jun 1993 00:16:13 +0000 (16:16 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 8 Jun 1993 00:16:13 +0000 (16:16 -0800)
Work on file usr/src/contrib/news/trn3/filexp

Synthesized-from: CSRG/cd3/4.4BSD-Lite2

usr/src/contrib/news/trn3/filexp [new file with mode: 0644]

diff --git a/usr/src/contrib/news/trn3/filexp b/usr/src/contrib/news/trn3/filexp
new file mode 100644 (file)
index 0000000..6437329
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+: expand filename
+case "$1" in
+ ~/*|~)
+       echo $1 | /usr/bin/sed "s|~|${HOME-$LOGDIR}|"
+       ;;
+ ~*)
+       if /bin/test -f /bin/csh; then
+               /bin/csh -f -c "glob $1"
+               failed=0
+               echo ""
+               exit $failed
+       else
+               name=`/bin/expr x$1 : '..\([^/]*\)'`
+               dir=`/usr/bin/sed -n -e "/^${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e p -e q -e '}' </etc/passwd`
+               if /bin/test ! -d "$dir"; then
+                       me=`basename $0`
+                       echo "$me: can't locate home directory for: $name" >&2
+                       exit 1
+               fi
+               case "$1" in
+               */*)
+                       echo $dir/`/bin/expr x$1 : '..[^/]*/\(.*\)'`
+                       ;;
+               *)
+                       echo $dir
+                       ;;
+               esac
+       fi
+       ;;
+*)
+       echo $1
+       ;;
+esac