Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 945 Bytes

notes.md

File metadata and controls

22 lines (15 loc) · 945 Bytes
  1. interactivity is not possible in BASH, with strings as return value.

    There are workarounds in this case.

    1. You can return numbers with newly defined set of rules that will work as hash codes.
    2. You can use a global helper variable.

    The first one is minimal but overly complex. The second one creates some weird rules. But the 2nd rule can be generalized with introducing some conventions.

    To achieve the 2nd goal, you can introduce a global variable $RETURN_VALUE, which will store the return value of the last called function. In this case, it will be the same as passing reference in C, and using void function to manipulate the dereferenced variable's value.

  2. There are two ways to call an argument.

    1. func ${ARRAY[@]}
    2. func "${ARRAY[@]}"s

    The first will split the argument into numerous arguments, and the second will have only one argument, a string of the array.