mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-11-05 18:56:14 +08:00
SC2164: show two possible variants for circumenting the warning
always calling 'exit' is not good in e.g. functions. the basic idea is at least that the returncode of cd *is* evaluated somehow and not ignored. Reported-by: Garance Alistair Drosehn <drosehn@rpi.edu> Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>
This commit is contained in:
@@ -2514,7 +2514,7 @@ checkUncheckedCd params root =
|
|||||||
when(t `isUnqualifiedCommand` "cd"
|
when(t `isUnqualifiedCommand` "cd"
|
||||||
&& not (isCdDotDot t)
|
&& not (isCdDotDot t)
|
||||||
&& not (isCondition $ getPath (parentMap params) t)) $
|
&& not (isCondition $ getPath (parentMap params) t)) $
|
||||||
warn (getId t) 2164 "Use cd ... || exit in case cd fails."
|
warn (getId t) 2164 "Use 'cd ... || exit' or 'cd ... || return' in case cd fails."
|
||||||
checkElement _ = return ()
|
checkElement _ = return ()
|
||||||
isCdDotDot t = oversimplify t == ["cd", ".."]
|
isCdDotDot t = oversimplify t == ["cd", ".."]
|
||||||
hasSetE = isNothing $ doAnalysis (guard . not . isSetE) root
|
hasSetE = isNothing $ doAnalysis (guard . not . isSetE) root
|
||||||
|
|||||||
Reference in New Issue
Block a user