When I reference $0 in a Bash script on my Mac running Mac OS X v10.6.7 (Snow Leopard), I get -bash
, not the name of the script.
I ran the script described in this Stack Overflow question:
#!/bin/bash
echo
echo '# arguments called with ($@) --> '"$@"
echo '# $1 --------------------------> '"$1"
echo '# $2 --------------------------> '"$2"
echo '# path to me ($0) -------------> '"$0"
echo '# parent path (${0%/*}) -------> '"${0%/*}"
echo '# my name (${0##*/}) ----------> '"${0##*/}"
echo
The following is produced:
> . show_parms.sh foo
# arguments called with ($@) --> foo
# $1 --------------------------> foo
# $2 -------------------------->
# path to me ($0) -------------> -bash
# parent path (${0%/*}) -------> -bash
# my name (${0##*/}) ----------> -bash
Any ideas?