Summary

  • In this Hackaday article the writer explains some oddities of Bash, a widely used default shell along with some programming features.
  • Most shell programmers are used to the concept of “call by reference” where you pass a reference to a variable and it acts more as an “input” than a “destination” for the function.
  • In bash parameters sometimes behave like “call by value”, sometimes like “call by reference” which can be confusing.
  • Also, it is possible and easy to change variables in an upper scope and the scope of variables in bash is dynamic and not static.
  • To avoid these oddities when programming in Bash, some best practices are suggested throughout the article.

Unfortunately, the new Hackaday comment filter has begun blocking legitimate comments and links along with spam. I have reported this to their team and hope they fix it soon.

By Al Williams

Original Article