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.

Bob


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to