bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

passing arrays as parameters to functions


From: sharkura
Subject: passing arrays as parameters to functions
Date: Fri, 17 Apr 2009 09:29:29 -0700 (PDT)

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 ${arrayArg[@]}, 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.

Any suggestions?

Thanks

¦ {Þ
-- 
View this message in context: 
http://www.nabble.com/passing-arrays-as-parameters-to-functions-tp23101104p23101104.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]