man uawhich
NAME
uawhich - Identify where in PATH something executes
SYNOPSIS
uawhich[-options] program [program...]
DESCRIPTION
The uawhich command identifies where in PATH something executes. It is comparable
to which which primarily operates under csh although may work under ksh. Note some
implementations of ksh include a built-in whence intended to be used instead of
which. Confusing, eh? That is the primarily reason to use uawhich so you know
what is actually executing under any shell.
OPTIONS
-first
First only option, comparable to standard which.
Useful returning full command which will execute:
# COMMAND=`uawhich -f cp`
-read
Read check, default check is for execute access.
Useful for command files read by utilities.
-xr
Read and execute check (for scripts).
Must specify "-xr".
-verbose
Verbose option to display errno if set.
Utilizes a call to system().
-uals
Display filename(s) via uals (enhanced ls).
Defaults as "uals -L" to show attributes via symbolic link.
-Uoptions
Display filename(s) via "uals -options".
-ls
Display filename(s) via "ls -l".
Utilizes a call to system().
-Loptions
Display filename(s) via "ls -options".
-l
Display filename(s) space separated vs. separate lines.
-path
Display path.
-?
Display terse help message.
EXAMPLES
For comparison purposes, whereis and which (IRIX):
leinie: whereis cp
cp: /bin/cp /usr/bin/cp /sbin/cp /usr/share/catman/u_man/cat1/cp.z
leinie: which cp
/sbin/cp
All matches:
leinie: uawhich cp
/sbin/cp
/usr/bin/cp
/bin/cp
First match:
leinie: uawhich -f cp
/sbin/cp
Verbose:
leinie: uawhich -v cp
/usr/sbin /cp ! No such file or directory
/sbin/cp
/usr/bsd /cp ! No such file or directory
/usr/bin/cp
/bin/cp
/usr/local/bin /cp ! No such file or directory
With -ls option:
java: uawhich -ls cp
-rwxr-xr-x 1 bin bin 24576 Jul 24 1995 /usr/bin/cp
-rwxr-xr-x 1 bin bin 139264 Jul 24 1995 /sbin/cp
For comparison (Digital UNIX), note which is broken for status and capturing pro-
gram name:
nugget: which X
no X in /usr/bin /usr/sbin /sbin /usr/local/bin
nugget: echo $? # status should be 1, but is not
0
nugget: xx=`which X`
nugget: echo $xx # note, it used stdout not stderr
no X in /usr/bin /usr/sbin /sbin /usr/local/bin
Better behaviour where status is non-zero and stdout is not used if file not found
in PATH:
nugget: uawhich X
nugget: echo $? # status is actually non-zero
1
nugget: xx=`uawhich X`
nugget: echo $xx # and stdout is was null
NOTES
uawhich has been tested under Digital UNIX, IRIX, and UNICOS[/mk].
This command utilizes the cci command parser utilized by non-UNIX operating systems
instead of the traditional UNIX getopt() parsing. Options have been defined to
"look like" UNIX style options, but can be spelled out or generally abbreviated.
For example -v is the same as -verbose. Because of this multiple options must be
space separated and the hyphen is part of the option name. Also because of this
order of options and arguments is irrelevant.
Both the -uals and -ls option invoke via system() calls.
ACKNOWLEDGEMENTS
Written at the University of Alaska. Ongoing maintenance via SourceForge by Denali
Sun Consulting.
Suggestions or bug reports can be directed to denalisun907@gmail.com.
RELATED INFORMATION
Commands: whereis(1), which(1). ksh(1,reference:whence).