On Friday 17 April 2009 12:29:29 sharkura wrote:
> I am looking for a way to pass an array variable as an argument to a
> function.  The only remotely similar post I found dealt with spaces in
> arguments, which is not my problem.
>
> I want to pass three arguments to a function.  I want to receive them as
> three positional parameters, $1 (an array), $2 (a scalar integer), and $3
> (another scalar integer).  The integers are optional.
>
> Currently, if I pass my array argument as ${arraya...@]}, the contents
> actually expand to positional parameters $1, $2, ... $N.  I could just
> assume that the last two positional parameters are my two integer
> arguments, but I'd like them to be optional.  The size of the array is not
> fixed.
>
> I've googled and searched this forum, but all the examples I've found use a
> global array that is not passed as an argument, but defined prior to the
> function that uses it.   Kind of ugly to me, but a solution if no other
> exists.

other options:
 - rebuild array using $@
 - pass var by reference and duplicate it manually in the function:
        do_something arrayArg

otherwise, what you mention is best i could think of real quick ...
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to