bug-coreutils
[Top][All Lists]
Advanced

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

Re: basename -bash generates an error


From: Eric Blake
Subject: Re: basename -bash generates an error
Date: Wed, 18 Apr 2007 21:06:59 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Brian Matheson on 4/18/2007 8:34 PM:
> Old behavior:
> red:~$ basename $0
> -bash

Broken.

> 
> New behavior:
> orange:~/lib/sh$ basename $0
> basename: invalid option -- b
> Try `basename --help' for more information.

Correct behavior, but undesired results.

So what you really wanted to do:

basename -- "$0"

This correctly handles the case when $0 contains shell metacharacters, as
well as when it starts with -.

> 
> Looks like a misbehavior in option parsing.

No, just a misunderstanding on your part.  POSIX requires the current
behavior.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGJtzR84KuGfSFAYARAi9SAKC1lELw/+J6mLYBQ8hyIRcOAwWn9ACg1apm
cs2wFv7zfGaZDV95JD6nxYc=
=79ow
-----END PGP SIGNATURE-----




reply via email to

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