Here's a snippet or screenshot that shows the problem:
#!/usr/bin/env sh
# shellcheck enable=all
my_func()
{
if test "${1-}" = '-' && test "${#}" -eq 1; then
(
# shellcheck disable=SC2030 # Intended: Modification of LC_ALL is local (to subshell)
LC_ALL='C'
export LC_ALL
some_code
)
else
_old_lcall="${LC_ALL-}"
LC_ALL='C'
export LC_ALL
some_other_code
if test -n "${_old_lcall?}"; then LC_ALL="${_old_lcall:?}"; else unset LC_ALL; fi
fi
}
my_func '-'
Here's what shellcheck currently says:
[Line 15:](javascript:setPosition(15, 17))
_old_lcall="${LC_ALL-}"
^-- [SC2031](https://www.shellcheck.net/wiki/SC2031) (info): LC_ALL was modified in a subshell. That change might be lost.
Here's what I wanted or expected to see:
Nothing.
Since the subshell is in a different code path it cannot affect the code at line 15 so it shouldn't report it.
For bugs
shellcheck --version
or "online"): onlineHere's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
Nothing. Since the subshell is in a different code path it cannot affect the code at line 15 so it shouldn't report it.