1case $CONFIG in
2    '') . ./config.sh ;;
3esac
4echo "Extracting filexp (with variable substitutions)"
5$spitshell >filexp <<!GROK!THIS!
6$startsh
7sed=${sed-sed}
8expr=${expr-expr}
9basename=${basename-basename}
10test=${test-test}
11prefix=${prefix-invalid}
12!GROK!THIS!
13$spitshell >>filexp <<'!NO!SUBS!'
14: expand filename
15case "$1" in
16 ~/*|~)
17	echo $1 | $sed "s|~|${HOME-$LOGDIR}|"
18	;;
19 ~~/*|~~)
20	echo $1 | $sed "s|~~|${TRNPREFIX-$prefix}|"
21	;;
22 ~*)
23	if $test -f /bin/csh; then
24		/bin/csh -f -c "glob $1"
25		failed=$?
26		echo ""
27		exit $failed
28	else
29		name=`$expr x$1 : '..\([^/]*\)'`
30		dir=`$sed -n -e "/^${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e p -e q -e '}' </etc/passwd`
31		if $test ! -d "$dir"; then
32			me=`$basename $0`
33			echo "$me: can't locate home directory for: $name" >&2
34			exit 1
35		fi
36		case "$1" in
37		*/*)
38			echo $dir/`$expr x$1 : '..[^/]*/\(.*\)'`
39			;;
40		*)
41			echo $dir
42			;;
43		esac
44	fi
45	;;
46*)
47	echo $1
48	;;
49esac
50!NO!SUBS!
51chmod +x filexp
52$eunicefix filexp
53