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: Wed, 26 Jan 2005 12:28:13 -0500
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)

Stepan Kasal <address@hidden> wrote:
> Autoconf manual warns that not all hosts have dirname, even though it
> doesn't mention any OS.  This claim could be still true.

sed, then?  This could handle the "case" test, too:

dir=`sed '
1h
1!H
$!d
g
s%[^/]*$%%
' <<EOT
$0
EOT
`

The first four sed commands are there to handle paths with newlines:
all the input is collected into one buffer before the rest of the
processing.  This works for me with bash, pdksh, and /bin/sh on
{Free,Net,Open}BSD and Solaris.

> What does Solaris do with  ${0%/*} ?  I hope it expands to an empty string.

No:
$ echo ${0%/*}
bad substitution
$ 
(Note there is no empty line; echo did not run at all.)

You could probe to see if it's supported like this:
if { : ${0%/*}; } 2> /dev/null; then ...
but that test itself will spawn an extra process on some shells (due
to redirections applied to a compound command), including Solaris
/bin/sh.

>   */*) dir=${0%/*}/

So this won't set dir at all.


paul




reply via email to

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