-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC3043
ILoveGoulash edited this page Nov 22, 2024
·
4 revisions
myfunc() {
local i=0
..
}
In POSIX sh, you can adopt some convention to avoid accidentally overwriting variables names, e.g. prefixing with the function name:
myfunc() {
_myfunc_i=0
..
}
local
is supported in many shells, including bash, ksh, dash, and BusyBox ash. However, strictly speaking, it's not POSIX (rationale).
Since quite a lot of real world shells support this feature, you may decide to ignore the warning.
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!