ShBash · Lesson 4 of 8
Functions
Bash functions are reusable blocks of code. They work differently from functions in other languages — no return values, just exit codes and stdout.
◆ Note
Use local for all variables inside functions. Without local, Bash variables are global by default — a function setting x=5 would change a global x variable, which is a nasty source of bugs.
Use local for all variables inside functions. Without local, Bash variables are global by default — a function setting x=5 would change a global x variable, which is a nasty source of bugs.