Positional Parameter Settin in function

Stephen Vinoski vinoski at apollo.COM
Fri Jun 9 00:01:00 AEST 1989


In article <570024 at hpsemc.HP.COM> gph at hpsemc.HP.COM (Paul Houtz) writes:
>
>In my ksh, the "set" command doesn't seem to work within a function:
>
>    $ set `date`
>    $ echo $4
>    16:31:00
>
>Now if I declare a function:
>
>    $ foo () {
>     /    set `date`
>     /    }
> 
>    $ foo
>    $ echo $4
>    16:31:00
>
>As you can see, the old `date` is still in the positional parameters, otherwise
>the seconds part of the date should have changed by now.  

In ksh, positional parameters are not shared between the function and its
caller.

Try "The Kornshell Command and Programming Language", Morris I. Bolsky and David
G. Korn, Prentice-Hall, 1989, ISBN 0-13-516972-0.  It's a great book.


-steve
-- 
  Steve Vinoski       ## Apollo, a Subsidiary of HP ## ARPA: vinoski at apollo.com
  (508)256-6600 x5904 ## Chelmsford, MA  01824      ## UUCP: ...!apollo!vinoski
  "...no hardware designer should be allowed to produce any piece of hardware
   until 3 software guys have signed off for it."   -Andy Tanenbaum



More information about the Comp.unix.wizards mailing list