Re: $0 variation questions
- From: Bit Twister <BitTwister@xxxxxxxxxxxxxxxx>
- Date: Sun, 30 Jan 2011 23:29:14 +0000 (UTC)
On Sun, 30 Jan 2011 15:00:13 -0800, Todd wrote:
I mean the run line variables ($1 $2 etc.). And I was
mistaken. I thought $0 included then.
When in doubt, use echo $some_var_here or better yet
echo " >$some_var_here<" to detect any leading/trailing white space.
I still have to figure out how to get the
full path and name of the script.
You already know how to get name of script.
As you have seen, ./script_fn, bit you, and if you look at $PATH the
script could be in one or more places.
You can test first character for . and if so use $PWD.
Then run result through type. Here is a quick untested kludge
_exe=$0
_char1=${$_exe:0:1}
if [ "$_char1" = "." ] ; then
_exe=$PWD/${$_exe:2}
fi
set -- $(type $0)
_fn=$1
_dir=${3%$_fn}
echo $_fn $_dir
.
- References:
- Re: $0 variation questions
- From: Bit Twister
- Re: $0 variation questions
- From: Todd
- Re: $0 variation questions
- Prev by Date: Re: $0 variation questions
- Next by Date: Re: VLC: how NOT to get a maximized window
- Previous by thread: Re: $0 variation questions
- Next by thread: Re: $0 variation questions
- Index(es):
Relevant Pages
|