Mail Archives: cygwin/1999/02/11/02:56:35
> ----------
> From: Luke Kendall
> Sent: 1999$BG/(J2$B7n(J11$BF|(J 11:31:21
(J> To: uwin-users AT research DOT att DOT com
> Subject: A useful script
> Auto forwarded by a Rule
>
An off-list discussion with Christopher Vickers lead me
to think that a small donation of a utility might be of
some value to some people. "whiches" lists all the
possible commands, in PATH order, for the supplied arguments.
> > > Interesting. It doesn't work that way under MKS or U/WIN ksh.
> > > bash's "type -a" does, however.
[...]
> But I do wish that whence -a did what your whiches does as
> well as what it does.
> Chris
An extra option to whence, that didn't stop at the first
command found would be useful.
Here is the script. It can be considerably simplified if
you only want it to work in a truly Unix compatible environment
like U/WIN.
----------------- whiches ---------------------
#!/bin/sh
#
# whiches -- print full pathnames of executable args.
#
# Author: Luke Kendall
. portshell
if [ $# = 0 ]
then
echo "usage: `basename $0` command-names" >&2
exit 2
fi
exstat=1
#
# If the path contains semi-colons, it's almost guaranteed to
# be because we're on Windows and using a non-Unix PATH syntax.
#
if expr "$PATH" : ".*;" > $DEVNULL
then
IFS="; "
else
IFS=": "
fi
#
# Cygnus bash 19.1 doesn't understand its own UNC PATH name conventions
# when used as an ordinary file path. Sigh.
#
if [ "x$BASH" = "x" ]
then
remap=false
else
remap=true
fi
for i
do
if expr "x$i" : "x.*/.*" > $DEVNULL
then
test -x $i && test ! -d $i && echo $i && exstat=0
else
for j in $PATH
do
$remap && j=`echo "$j" | sed 's|^//*\([A-Za-z]\)/|\1:/|'`
for suff in "" ".exe" ".sh" ".com" ".bat" ".ksh" ".dll"
do
k="$i$suff"
test -x "$j/$k" && echo "$j/$k" && exstat=0
done
done
fi
done
exit $exstat
------------------ portshell ---------------------
#!/bin/sh
#
# Set some variables to make DOS-portable shell scripts possible.
# This script must be sourced by a Bourne-like shell to be effective:
#
# . portshell
#
# Author: Luke Kendall
#
VARS="DEVTTY DEVNULL EGREP_SILENT TMP SEARCH_SEP"
if test -w /dev/null
then
DEVTTY=/dev/tty
DEVNULL=/dev/null
EGREP_SILENT="s"
TMP=${TMP:-/tmp}
else
DEVTTY=con
DEVNULL=nul
EGREP_SILENT="q"
TMP=${TMP:-$TEMP}
if [ "x$TMP" = "x" ]
then
if [ -d c:/tmp ]
then
TMP=c:/tmp
elif [ -d c:/temp ]
then
TMP=c:/temp
else
echo "Couldn't work out what to set TMP to" >&2
fi
fi
fi
#
# If the path contains semi-colons, it's almost guaranteed to
# be because we're on Windows and using a non-Unix PATH syntax.
#
if expr "$PATH" : ".*;" > $DEVNULL
then
SEARCH_SEP=";"
else
SEARCH_SEP=":"
fi
export $VARS
unset VARS
____________________________________________________________
If you need help unsubscribing or using this list in
general, send mail to owner-uwin-users AT research DOT att DOT com
To unsubscribe from this list, please send the following
two-line message to majordomo AT research DOT att DOT com, in which
your_email_address should be replaced by the address you
used when you subscribed to the list:
unsubscribe uwin-users your_email_address
end
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -