Skip to content

Commit

Permalink
Recommend typeset instead of declare in SC2324
Browse files Browse the repository at this point in the history
Bash has both `typeset` and `declare`, but ksh has `typeset` only.
Recommend the more portable alternative to users.
  • Loading branch information
larryv committed Mar 8, 2024
1 parent 50db9a2 commit 9cb21c8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ShellCheck/Analytics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5017,7 +5017,8 @@ checkPlusEqualsNumber params t =
state <- CF.getIncomingState cfga id
guard $ isNumber state word
guard . not $ fromMaybe False $ CF.variableMayBeDeclaredInteger state var
return $ warn id 2324 "var+=1 will append, not increment. Use (( var += 1 )), declare -i var, or quote number to silence."
-- Recommend "typeset" because ksh does not have "declare".
return $ warn id 2324 "var+=1 will append, not increment. Use (( var += 1 )), typeset -i var, or quote number to silence."
_ -> return ()

where
Expand Down

0 comments on commit 9cb21c8

Please sign in to comment.