Re: script name w/o path.

2009-08-08 Thread John Summerfield

John McKown wrote:

Yes, I know how to get it. But I'm curious and would like your feedback.
Assuming that my script is BASH specific, is there any reason why I should
not use the command:

SCRIPT_NAME=${0##*/}

instead of

SCRIPT_NAME=$(basename $0)

?

I ask because I feel that the first example, though not universal to all
shells, is worth it due to being more efficient. I don't fork() a new
process or need to run an external program.

I also know this might not matter much to Linux, even on a z. But the
first also works in z/OS with its default shell, and that saves me CPU
which saves me money. Well, saves the company money, actually.


How many times is this being done?

How much time and trouble are you expending trying to sort this out?

How well are likely readers to understand what SCRIPT_NAME=${0##*/} does?

Me, I'd choose using basename,unless I knoew a really good reason not
to, and if the script is going to be used enough that it matters,
there's a good argument it shouldn't be a script at all, but rather
compiled code in an appropriate programming language.




--

Cheers
John

-- spambait
1...@coco.merseine.nu  z1...@coco.merseine.nu
-- Advice
http://webfoot.com/advice/email.top.php
http://www.catb.org/~esr/faqs/smart-questions.html
http://support.microsoft.com/kb/555375

You cannot reply off-list:-)

--
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390


script name w/o path.

2009-08-07 Thread John McKown
Yes, I know how to get it. But I'm curious and would like your feedback.
Assuming that my script is BASH specific, is there any reason why I should
not use the command:

SCRIPT_NAME=${0##*/}

instead of

SCRIPT_NAME=$(basename $0)

?

I ask because I feel that the first example, though not universal to all
shells, is worth it due to being more efficient. I don't fork() a new
process or need to run an external program.

I also know this might not matter much to Linux, even on a z. But the
first also works in z/OS with its default shell, and that saves me CPU
which saves me money. Well, saves the company money, actually.

--
Trying to write with a pencil that is dull is pointless.

Maranatha!
John McKown

--
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390