0

Hi!

Long time since i done any bash scripting.

Is it possible to pass a arguments in functions?

Something like:

recivefunc(SOMETHING)
{
echo $SOMETHING
}

passingfunc()
{
SOMETHING=test
recivefunc($SOMETHING)
}
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by nezachem
0
receivefunc()
{
    echo $1
}

I know how to catch arguments from terminal.

I guess its not possible to pass arguments from function to function in bash script like in ordinary programming language since i cant find any information about it.

0

Of course you can. They just don't have names. They are positional, and are referred as $1, $2, etc. The $1 used in a function is a first argument passed to it.

> since i cant find any information about

That's strange, because TFM clearly says:

When a function is executed, the arguments to the function become the positional parameters during its execution. The special parameter # is updated to reflect the change. Special parameter 0 is unchanged.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.