tags:

views:

36

answers:

3

Is the number of arguments that a bash function can accept limited?

+2  A: 

You could look at what

getconf ARG_MAX

outputs on your computer.

Alberto Zaccagni
+2  A: 

The bash manual says:

There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously.

I believe this applies, since function arguments are presented as an array.

unwind
A: 

To access arguments in a function, you can iterate over them:

foo () {
    for arg    # "in $@" is implied
    do
        echo $arg
    done
}

or

bar () {
    while [ $1 ]
    do
        echo $1
        shift
    done
}

or to access specific arguments:

baz () {
    # for arguments above $9 you have to use curly braces
    echo $1 $9 ${10} ${121375}
}
Dennis Williamson