Commit | Line | Data |
---|---|---|
d8875586 MBT |
1 | ?RCS: $Id: Filexp.U 1 2006-08-24 12:32:52Z rmanfredi $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi | |
4 | ?RCS: | |
5 | ?RCS: You may redistribute only under the terms of the Artistic Licence, | |
6 | ?RCS: as specified in the README file that comes with the distribution. | |
7 | ?RCS: You may reuse parts of this distribution only within the terms of | |
8 | ?RCS: that same Artistic Licence; a copy of which may be found at the root | |
9 | ?RCS: of the source tree for dist 4.0. | |
10 | ?RCS: | |
11 | ?RCS: $Log: Filexp.U,v $ | |
12 | ?RCS: Revision 3.0.1.2 1994/10/29 15:52:53 ram | |
13 | ?RCS: patch36: added ?F: line for metalint file checking | |
14 | ?RCS: patch36: added HOME to the ?T: line since metalint now checks ${HOME} | |
15 | ?RCS: | |
16 | ?RCS: Revision 3.0.1.1 1994/05/06 14:03:00 ram | |
17 | ?RCS: patch23: made sure error status from csh is propagated (WED) | |
18 | ?RCS: | |
19 | ?RCS: Revision 3.0 1993/08/18 12:04:53 ram | |
20 | ?RCS: Baseline for dist 3.0 netwide release. | |
21 | ?RCS: | |
22 | ?X: | |
23 | ?X: This unit produces a shell script which will expand filenames beginning | |
24 | ?X: with tildes. The script is deleted at the end of Configure. | |
25 | ?X: | |
26 | ?MAKE:Filexp: startsh sed test expr eunicefix | |
27 | ?MAKE: -pick add $@ %< | |
28 | ?F:./filexp | |
29 | ?T:HOME LOGDIR dir me name failed | |
30 | : set up shell script to do ~ expansion | |
31 | cat >filexp <<EOSS | |
32 | $startsh | |
33 | : expand filename | |
34 | case "\$1" in | |
35 | ~/*|~) | |
36 | echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|" | |
37 | ;; | |
38 | ~*) | |
39 | if $test -f /bin/csh; then | |
40 | /bin/csh -f -c "glob \$1" | |
41 | failed=\$? | |
42 | echo "" | |
43 | exit \$failed | |
44 | else | |
45 | name=\`$expr x\$1 : '..\([^/]*\)'\` | |
46 | dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\` | |
47 | if $test ! -d "\$dir"; then | |
48 | me=\`basename \$0\` | |
49 | echo "\$me: can't locate home directory for: \$name" >&2 | |
50 | exit 1 | |
51 | fi | |
52 | case "\$1" in | |
53 | */*) | |
54 | echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\` | |
55 | ;; | |
56 | *) | |
57 | echo \$dir | |
58 | ;; | |
59 | esac | |
60 | fi | |
61 | ;; | |
62 | *) | |
63 | echo \$1 | |
64 | ;; | |
65 | esac | |
66 | EOSS | |
67 | chmod +x filexp | |
68 | $eunicefix filexp | |
69 |