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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1994-2011 AT&T Intellectual Property #
# and is licensed under the #
# Eclipse Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# Glenn Fowler <gsf@research.att.com> #
# #
########################################################################
: wrapper for .exe challenged win32 systems/commands
command=execrate
case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
0123) ARGV0="-a $command"
USAGE=$'
[-?
@(#)$Id: execrate (AT&T Labs Research) 2002-02-02 $
]
'$USAGE_LICENSE$'
[+NAME?execrate - wrapper for .exe challenged commands]
[+DESCRIPTION?\bexecrate\b runs \acommand\a after checking the \afile\a
operands for standard semantics with respect to \bwin32\b \b.exe\b
suffix conventions. This command is only needed on \bwin32\b
systems that inconsistently handle \b.exe\b across library and
command interfaces. \acommand\a may be one of \bcat\b(1), \bchmod\b(1),
\bcmp\b(1), \bcp\b(1), \bln\b(1), \bmv\b(1), or \brm\b(1).
Only the 2 argument forms of \bcp\b, \bln\b and \bmv\b are handled.
Unsupported commands and commands requiring no change are
silently executed.]
[+?With no arguments \bexecrate\b exits with status 0 if the current system
is \b.exe\b challenged, 1 if the current system is normal.]
[n:show?Show the underlying commands but do not execute.]
command [ option ... ] file ...
[+SEE ALSO?\bwebster\b(1)]
'
usage()
{
OPTIND=0
getopts $ARGV0 "$USAGE" OPT '-?'
exit 2
}
exec=1
while getopts $ARGV0 "$USAGE" OPT
do case $OPT in
n) exec=0 ;;
*) usage ;;
esac
done
shift `expr $OPTIND - 1`
;;
*) usage()
{
echo "Usage: execrate [ -n ] [ command [ option ... ] file ... ]" >&2
exit 2
}
exec=1
while :
do case $1 in
-n) exec=0 ;;
-*) usage ;;
*) break ;;
esac
shift
done
;;
esac
case $# in
0) if test ! -x /bin/cat.exe
then exit 1 # normal
fi
then exit 1 # normal
fi
exit 0 # challenged
;;
1) usage
;;
esac
case $1 in
*cat|*rm)
NUM=0
;;
*chgrp|*chmod)
NUM=1
;;
*cmp|*cp|*ln|*mv)
NUM=2
;;
*) case $exec in
0) echo "$@" ;;
*) "$@" ;;
esac
exit
;;
esac
CMD=$1
shift
case $CMD in
*/*) ;;
*) for d in $bins
do if test -x $d/$1 -o -x $d/$1.exe
then CMD=$d/$1
break
fi
done
;;
esac
while :
do case $1 in
-*) CMD="$CMD $1" ;;
*) break ;;
esac
shift
done
case $exec in
0) CMD="echo $CMD" ;;
esac
case $NUM:$# in
*:0) ;;
1:*) CMD="$CMD $1"
NUM=0
shift
;;
esac
case $NUM:$# in
0:*) status=0
for f
do if test "$f" -ef "$f".exe
then f=$f.exe
fi
$CMD "$f"
case $? in
0) ;;
*) status=$? ;;
esac
done
exit $status
;;
2:2) f=$1
case $f in
*.exe) ;;
*) if test "$f" -ef "$f".exe
then f=$f.exe
fi
;;
esac
case $f in
*.exe) if test -d "$2"
then t=$2/$f
else t=$2
fi
case $t in
*/*) b=`basename "$t"` ;;
*) b=$t ;;
esac
case $b in
*.*) $CMD "$f" "$t"; exit ;;
*) $CMD "$f" "$t".exe; exit ;;
esac
;;
esac
;;
esac
$CMD "$@"