Re: doubt in a script
From: Dan Mercer (dmercer_at_mn.rr.com)
Date: 11/24/05
- Next message: Dan Mercer: "Re: How to search for string and assign the value on next line to a variable"
- Previous message: Dan Mercer: "Re: bullet proof for loop over $(find) in bash, how?"
- In reply to: Chris F.A. Johnson: "Re: doubt in a script"
- Next in thread: StrangeRover_at_gmail.com: "Re: doubt in a script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 24 Nov 2005 02:13:41 GMT
"Chris F.A. Johnson" <cfajohnson@gmail.com> wrote in message news:71id53-tgu.ln1@rogers.com...
: On 2005-11-23, Eric Haijun Xu wrote:
: > Chris F.A. Johnson wrote:
: >> On 2005-11-23, vishwa wrote:
: >> > Hi ,
: >> >
: >> > I have a doubt in one of the script i use, i want to know what the
: >> > below line does
: >> > typeset TOOLCMD=${0##*/}
: >>
: >> Put this in a script and try it:
: >>
: >> TOOLCMD=${0##*/}
: >> printf "\$0=%s\n" "$0"
: >> printf "TOOLCMD=%s\n" "$TOOLCMD"
: >>
: >>
: >> I wouldn't use the typeset command; read your shell man page to
: >> see what it does.
: >
: > "typeset cmd" is used to define a local variable in a function. why you
: > would not use it?
:
: Becasue it doesn't work in ksh93 unless you use the non-portable
: format for defining functions.
It's perfectly portable to other ksh's. If you are using ksh, your only
portability concern should be to other ksh's, in which the "function"
syntax IS the portable way to define local variables. Portability
is vastly overrated. The Bourne shell is virtually extinct and ash
is used only by extremists.
Besides, it does so much more than creating local variables, it
also determines how they'll be used an expressed (integer, [floating point],
Left justified and truncated, right justified and truncated, upper case, lower
case, [associative array], zero filled...
Dan Mercer
:
: Because "local" makes much more sense for that command.
:
: Because I don't like that use of the word (as a former graphic
: designer and typesetter, it just seems wrong). ;)
:
:
: --
: Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
: Shell Scripting Recipes: | My code in this post, if any,
: A Problem-Solution Approach | is released under the
: 2005, Apress | GNU General Public Licence
- Next message: Dan Mercer: "Re: How to search for string and assign the value on next line to a variable"
- Previous message: Dan Mercer: "Re: bullet proof for loop over $(find) in bash, how?"
- In reply to: Chris F.A. Johnson: "Re: doubt in a script"
- Next in thread: StrangeRover_at_gmail.com: "Re: doubt in a script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|