Subject: bug#8420: I: bug#8420: dirname

From: "Michele Marigliano" <[email-masked]>
Date: Mon, 4 Apr 2011 19:37:07 +0200

Ooopss....

-----Messaggio originale-----
Da: Michele Marigliano [mailto:[email-masked]] 
Inviato: lunedì 4 aprile 2011 18.32
A: 'Eric Blake'
Oggetto: R: bug#8420: dirname

Thanks for your reply.

I agree with you, but I was installing some software on RH 5.3 and when I
was going to run a script it exit soon because its first line
(CURRENT_DIR=`/usr/bin/dirname $0`) was in error.
So I copyed that line in an interactive bash shell ad I noticed that

$ CURRENT_DIR=`/usr/bin/dirname $0`
/usr/bin/dirname: invalid option -- b

In a bash script $0 should be script name, so I didn't understand why it
didn't work.

In anycase I tried that line also on Centos 5.5 with same error, of course,
but when I tried it on RH 4.x it didn't report any error.
This was a quite strange, I thought, so I have reported you it to know if
this behavior is all right.

At end, I resolved it running the script in this way:
./script.sh
and NOT
. script.sh (my first run with error).

Bye
Michael

PS: sorry for my bad English.

-----Messaggio originale-----
Da: Eric Blake [mailto:[email-masked]] 
Inviato: lunedì 4 aprile 2011 18.02
A: Michele Marigliano
Cc: [email-masked]
Oggetto: Re: bug#8420: dirname

tag 8420 + invalid
thanks

On 04/04/2011 07:43 AM, Michele Marigliano wrote:
> Hi,
> 
>  
> 
> I execute the following bash command on RH 5.3
> 
> CURRENT_DIR=`/usr/bin/dirname $0`
> 
> /usr/bin/dirname: invalid option -- b

Thanks for the report.  However, this is not a bug in dirname, but in your
usage pattern.  You are invoking "dirname -bash", which dirname
(rightly) interprets as the attempt to be the -b option, but dirname does
not have a -b option.  You need to use -- to mark the end of options and the
start of arguments:

dirname -- "$0"

> dirname (GNU coreutils) 5.97

Wow, that's old.  The latest stable version is 8.10.

> $ /usr/bin/dirname --version
> 
> dirname (GNU coreutils) 5.2.1

Wow, that's even older, but same story.

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org