bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-grep] egrep and fgrep script assume path


From: Paul Jarc
Subject: Re: [bug-grep] egrep and fgrep script assume path
Date: Thu, 27 Jan 2005 09:55:26 -0500
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)

Stepan Kasal <address@hidden> wrote:
>   */*)        dir=${0%/*}/ 2>/dev/null

This doesn't suppress the error message.  It seems that to suppress
it, you must put the expansion inside a compound command, and apply
the redirection to that compound command.  That works because Solaris
sh spawns a subshell for a compound command with redirections, and the
error message would come from the child shell, whose stderr has been
redirected by the parent.

There might be other shells that fork in this case, but do support
advanced expansion, so this also means that the probe has to be done
separately from the actual use of the expansion:

if { dir=${0%/*} } 2> /dev/null; then
  dir=${0%/*}/
else
  dir=`dirname "$0"`
fi


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]