retitle 8575 basename usage question
tag 8575 notabug
thanks

On 04/28/2011 02:42 AM, Syed Nizamuddin wrote:
> Hi,
> 
> I get the following error .
> 
> basename: invalid option -- b
> Try `basename --help' for more information.
> basename: missing operand

Thanks for the report.  However, this is not a bug in basename, but in
your usage.

> 
> I have basename used as
> 
> CMDE=`\basename $0 .sh`

That's your problem.  $0 expanded to "-bash", so basename is trying to
parse -b as an option.  Instead, use:

basename -- "$0" .sh

to avoid issues with $0 having a leading '-'.  If you want to do more
reading about this topic, see a similar report about dirname:
http://debbugs.gnu.org/8420

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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to