It's a shell script, not a C program.
Unless you're writing a specifically low-level system utility (at which
point you could do better by picking a lower level language), meant to be
looped hundreds to thousands of times, the difference in using basename and
the bash built-in is too small to be
Correct, and the right way i might add on this specific part of the
script. You don't call basename often in my experience.
Sheepishly, My last e-mail was more of extending more information
rather than answering directly the question!
--
regards,
Andre | http://www.varon.ca
On Tue, Jun 3, 2008
On 6/3/08, Mark David Dumlao [EMAIL PROTECTED] wrote:
I read somewhere Programs are written to be read by people, and only
incidentally be executed by computers.
So I've always believed that
${0##*/} = generally bad
using bash env variables and basename = generally good
Don't discard good
yeah, I dont call basename many times in a script.
What I mean is I used basename often in my scripts.
Thanks for the responses. With this, I'm exploring now
bash brace expansions, shell expansions, etc. etc.
I think brace expansions have advantages, say
iterating through a non-integer indices.
ugh. Sounds like an ugly snippet i used to write for something. I showed it
to someone, he frowned (or I imagine he did, I looked at his face through an
internet forum), and told me to just use basename instead.
cmd=`basename $0` is more understandable.
On Mon, Jun 2, 2008 at 8:15 PM, fooler
Mark,
That is true on the surface, but the answer is it depends.
Convoluted internal built-in command shown is way faster especially if
this script is going to be called often, rather than executing
basename, which is an external command.
For a perspective, replacing echo and cat, and using
Thanks all,
I've been using basename $0 quite often until this one.
Thanks again.
_
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph
Hi all,
I saw in a script this line:
cmd=${0##*/} # Command's basename
Echoed the value of cmd and this returns -bash.
I cant seem to figure out how this works.
_
Philippine Linux Users' Group (PLUG) Mailing List
8 matches
Mail list logo