[GRASS-dev] hardcoded 'xterm': wrapper?

Glynn Clements glynn at gclements.plus.com
Mon Aug 28 07:23:16 EDT 2006


Hamish wrote:

> > One minor point: I thought that using "which" was advised against, as
> > it isn't present on all platforms.
> 
> On what platforms is it missing? If `which` is missing, what are the
> chances that other assumed unix tools are missing? (ie everything breaks)

I don't know, but SUBMITTING_SCRIPTS says:

  5.  If you search for a command in $PATH, do NOT
      use the "which" command or the "type -p" command. Both commands are not
      supported on all platforms, thus causing problems for some people. As an
      alternative, please use code similar to the following shell script snippet
      which will perform the same function. In this case, the path of the grass60
      command is saved if grass60 is found in $PATH. This won't recognize aliased
      command name.
  
  	# Search for grass5 command in user's path
  	for i in `echo $PATH | sed 's/^:/.:/
      	    	    		    s/::/:.:/g
  				    s/:$/:./
  				    s/:/ /g'`
  	do
  	    if [ -f $i/grass5 ] ; then
      		
  		# Save the path of the grass60 command
  		GRASS_PATH=$i/grass60
  		# Use the first one in user's path
  		break
  	    fi
  	done
  
  <?>
      If you must use "which", use as follows:
  
  	# check if we have awk
  	if [ ! -x "`which awk`" ] ; then
  	    echo "ERROR: awk required, please install awk or gawk first" 1>&2
  	    exit 1
  	fi
  </?>

> > If it is used, stderr should be redirected to /dev/null, to silence
> > the errors about x-terminal-emulator not being found.
> 
> On what platforms does `which` not return silence if the target isn't
> found?

The GNU version isn't silent:

	glynn at cerise:6.1 $ which foo
	which: no foo in (/opt/grass-6.3.cvs/bin:/opt/grass-6.3.cvs/scripts:<snip>)

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list