You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lucas Larson edited this page Jan 17, 2026
·
5 revisions
In POSIX sh, declare is undefined.
In addition to declare, the following also cause SC3044 failures as of v0.11.0: let, caller, builtin, complete, compgen, dirs, disown, enable, mapfile, readarray, pushd, popd, shopt, suspend, and typeset.
Problematic code:
#!/bin/shdeclare var="value"
or
#!/bin/shdeclare -r readonly
or
#!/bin/shdeclare ...
Correct code:
If assigning a simple variable outside of a function, skip declare all together:
var="value"
If declaring a variable read-only:
var=value
readonly var
If you are unable to find a suitable replacement, consider switching to a shell that supports declare:
#!/bin/bashdeclare ...
Indexed arrays, associative arrays, local variables, namerefs, and integer variables are not supported in POSIX sh. Either write around them, or switch to a shell that supports them.
Rationale:
The declare command is non-standard, and most of its functionality is not available across shells.
Either find a POSIX replacement, or switch to a shell that is guaranteed to support them.
Exceptions:
If your declare command is guarded by a check of the shell version, such as inspecting $BASH_VERSION, you can ignore this message.
Related resources:
Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!