Monthly Archives: July 2014

A crucial trick in writing scripts is to identify well-rounded subtasks and to enclose the needed commands into a function with a speaking name.

If you aim to use functions you need to know

  • syntax of function definition
  • ways to pass inputs
  • how to return outputs

We have a look at bashs function syntax. Which is a valid first line for a function definition?

foo ( ) {
foo( ) {
foo ( ){

Surprise: here, bash is as benign as most scripting languages, all four are valid. Apparently, the parser looks for the round brackets first and thereby can detect function definitions. So why cant it do similarly in case of assignments by looking for “=”?