[Techtalk] re: Bash functions with user-defined parameters

Berenice showercurtain2000 at yahoo.com
Wed Apr 30 03:34:07 EST 2003


Thanks for everyone your feedback. While messing around with that
extra variable "num1" I was doing this:

myfunction()
{
num1=$1
while [ $1 -le $2 ]
do
  echo $1
  num1=$(( $1 + 1 )) #I'm afraid num1=$(( $1 ++ )) doesn't work.
done
}

...Which was why it wasn't working, duh :p  Now it works fine :)


On Mon, 28 Apr 2003, Dan Richter wrote: 

> The "num1" should not be preceded by a dollar sign. I see that you 
> already know this, Bernice, but I wanted to make sure it didn't
slip > by you because it's the kind of mistake that's easy to miss.

:) Tell me about it!   I'm still getting used to stuff like parameter
expansion.  It's one of those things that you read, do it wrong
anyway; re-read and do correctly the next few tries; then suddenly
forget, make the same mistake and wonder why it doesn't work.


On Tue, 29 Apr 2003, Liz Young wrote:

> Thank you for posting your question, now I know a little more about

> bash scripting! :-)

Me too.  It's the first time I've seen the "let" command.


Berenice


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com


More information about the Techtalk mailing list