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's	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.

  -?	Display	terse help message.


EXAMPLES


  For comparison purposes, whereis and which (IRIX):

   kcarlson@leinie: whereis cp
   cp: /bin/cp /usr/bin/cp /sbin/cp /usr/share/catman/u_man/cat1/cp.z
   kcarlson@leinie: which cp
   /sbin/cp

  All matches:

   kcarlson@leinie: uawhich cp
   /sbin/cp
   /usr/bin/cp
   /bin/cp

  First	match:

   kcarlson@leinie: uawhich -f cp
   /sbin/cp

  Verbose:

   kcarlson@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:

   snkac@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 captur-
  ing program name:

   snkac@nugget: which X
   no X	in /usr/bin /usr/sbin /sbin /usr/local/bin
   snkac@nugget: echo $?  # status should be 1,	but isn't
   0
   snkac@nugget: xx=`which X`
   snkac@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:

   snkac@nugget: uawhich X
   snkac@nugget: echo $?  # status is actually non-zero
   1
   snkac@nugget: xx=`uawhich X`
   snkac@nugget: echo $xx # and	stdout is was null


NOTES


  uawhich has been tested under	Digital	UNIX, IRIX, and	UNICOS[/mk].  Sugges-
  tions	for enhancements or bug	reports	can be directed	to
  dutools@ts.sois.alaska.edu.

  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 gen-
  erally 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.


RELATED INFORMATION


  Commands: whereis(1),	which(1).  ksh(1,reference:whence).