[lug] question about ftp script...

arnie asherman1 at uswest.net
Tue Dec 14 21:02:08 MST 1999


Stephen Coffin wrote:

>
> The positional parameters are pushed onto a stack when the function starts,
> since the function can use "set" internally to replace them, and you
> don't want the function to over-write the original values in most
> cases.  This is why you can't see them inside the function.

> see a sample script below that does what you want.  There are probably

> several other ways to code this :-)
>
> like most UNIX things, experimentation and practice are very helpful :-)

I'm getting there, slowly...

>
>
> ##########################################################
> $ cat test_sh
>
> #!/bin/sh
>
> set ww ee rr tt
> echo $1 $2 $4
> X1=$1
> X2=$2
> X3=$3
> X4=$4
>
> function xxy () {
>         echo start
>         echo $X1 $X2 $X4
>         echo end
> }
>
> xxy
> echo Done!
>
> #########################################################

Well, what I ended up doing was just passing the parameters when I called the
function choice_1 in the case statement:

choice_1 $1 $2 $3 $4;;

and this worked. From your above comment though, I assume this is basically
passing by reference, and a function could trash the original values? Although
aren't these read only in this case?
thanks for your help,

--
arnie sherman
frenomulax at bigfoot.com

"Paradise is exactly like where you are right now,
 only much, much better."
        -Laurie Anderson








More information about the LUG mailing list