[Top][All Lists]

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

Re: basename -bash generates an error

From: Bob Proulx
Subject: Re: basename -bash generates an error
Date: Wed, 18 Apr 2007 21:11:48 -0600
User-agent: Mutt/1.5.9i

Brian Matheson wrote:
> I occasionally use basename $0 in scripts that I sometime source in my
> interactive shell.  This construct seems to be broken now.  
> Old behavior:
> red:~$ basename $0
> -bash
> New behavior:
> orange:~/lib/sh$ basename $0
> basename: invalid option -- b
> Try `basename --help' for more information.
> Looks like a misbehavior in option parsing.

Thank you for your report.  However this was an intentional change.
Documentation for intentional changes can be found in the NEWS file.
Here is the news concerning your issue.

  * Major changes in release 5.3.0 (2005-01-08)

  The following commands now reject unknown options instead of
  accepting them as operands, so that users are properly warned that
  options may be added later.  Formerly they accepted unknown options
  as operands; e.g., "basename -a a" acted like "basename -- -a a".

    basename dirname factor hostname link nohup sync unlink yes

To ensure correct operation for both old and new versions of the
command it is necessary to indicate the end of options using "--".
For example the following will do what you want.

  basename -- $0

That may similarly be applied to other commands to differentiate
options from arguments that may unintentionally start with an option
start character.


reply via email to

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