Michal Kordas
Michal Kordas

Reputation: 10925

Why Google Style Guide recommend local variables for shell scripts but does not use it in examples?

Google Style Guide says to always use local variables and put everything into function.

On the other hand sample for loop is provided:

for dir in ${dirs_to_cleanup}; do
  ...
done

Why there is no convention to always declare loop variable as local just before loop? Or maybe the following is the way how loops inside functions should be written to comply with the style guide?

local dir
for dir in ${dirs_to_cleanup}; do
  ...
done

Upvotes: 1

Views: 252

Answers (0)

Related Questions