Control
Shell functions, discussed in Chapter 26.
  1. Two different, equivalent syntaxes.
      function func1 { commands }
      func2 () { commands }
    1. The brackets need to be on lines as shown.
    2. The parens are just markers; you never list parameters.
    3. You can't return values in anything like familiar languages.
  2. Can be created in scripts or from the command line.
  3. Invoked like commands.
    1. Type the name of the function to run it.
    2. If you send parameters, they are available as $1, $2, etc.
    3. The return command produces a exit code available through $?, not an assignable return value.
    4. The usual way to get data back is through printing it, then VAR=$(command).
  4. Local variables.
    1. Inside a function, local vname
    2. This will now belong only to the function.
    3. Other variables are global.