File: filexp.SH

package info (click to toggle)
trn4 4.0-test77-18
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 4,016 kB
  • sloc: ansic: 48,332; sh: 6,795; tcl: 1,696; yacc: 662; perl: 108; makefile: 26
file content (52 lines) | stat: -rw-r--r-- 990 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting filexp (with variable substitutions)"
$spitshell >filexp <<!GROK!THIS!
$startsh
sed=${sed-sed}
expr=${expr-expr}
basename=${basename-basename}
test=${test-test}
prefix=${prefix-invalid}
!GROK!THIS!
$spitshell >>filexp <<'!NO!SUBS!'
: expand filename
case "$1" in
 ~/*|~)
	echo $1 | $sed "s|~|${HOME-$LOGDIR}|"
	;;
 ~~/*|~~)
	echo $1 | $sed "s|~~|${TRNPREFIX-$prefix}|"
	;;
 ~*)
	if $test -f /bin/csh; then
		/bin/csh -f -c "glob $1"
		failed=$?
		echo ""
		exit $failed
	else
		name=`$expr x$1 : '..\([^/]*\)'`
		dir=`$sed -n -e "/^${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e p -e q -e '}' </etc/passwd`
		if $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/`$expr x$1 : '..[^/]*/\(.*\)'`
			;;
		*)
			echo $dir
			;;
		esac
	fi
	;;
*)
	echo $1
	;;
esac
!NO!SUBS!
chmod +x filexp
$eunicefix filexp