3

I know I can write bash scripts like:

foo() { echo $1; } 

but can I define a function that writes:

foo(string) { echo $string; } 

I just can't find my way out of this.

    1 Answer 1

    5

    The only available form is the first one; see the manual for details.

    To use named parameters, the traditional technique is to assign them at the start of your function:

    foo() { string=$1 # ... echo "${string}" } 

      You must log in to answer this question.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.