Skip to content

Commit bc60607

Browse files
committed
fix(SC3012)!: do not warn about \< and \> in test/[] as specified in POSIX.1-2024
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/test.html fix #3168
1 parent d3001f3 commit bc60607

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- SC2002 about Useless Use Of Cat is now disabled by default. It can be
99
re-enabled with `--enable=useless-use-of-cat` or equivalent directive.
1010
- SC2015 about `A && B || C` no longer triggers when B is a test command.
11+
- SC3012: Do not warn about `\<` and `\>` in test/[] as specified in POSIX.1-2024
1112
### Fixed
1213
- SC2218 about function use-before-define is now more accurate.
1314
- SC2317 about unreachable commands is now less spammy for nested ones.

src/ShellCheck/Checks/ShellSupport.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ checkBashisms = ForShell [Sh, Dash, BusyboxSh] $ \t -> do
247247
unless isBusyboxSh $ warnMsg id 3010 "[[ ]] is"
248248
bashism (T_HereString id _) = warnMsg id 3011 "here-strings are"
249249
bashism (TC_Binary id SingleBracket op _ _)
250-
| op `elem` [ "<", ">", "\\<", "\\>", "<=", ">=", "\\<=", "\\>="] =
250+
| op `elem` [ "<", ">", "<=", ">=", "\\<=", "\\>="] =
251251
unless isDash $ warnMsg id 3012 $ "lexicographical " ++ op ++ " is"
252252
bashism (T_SimpleCommand id _ [asStr -> Just "test", lhs, asStr -> Just op, rhs])
253-
| op `elem` [ "<", ">", "\\<", "\\>", "<=", ">=", "\\<=", "\\>="] =
253+
| op `elem` [ "<", ">", "<=", ">=", "\\<=", "\\>="] =
254254
unless isDash $ warnMsg id 3012 $ "lexicographical " ++ op ++ " is"
255255
bashism (TC_Binary id SingleBracket op _ _)
256256
| op `elem` [ "-ot", "-nt", "-ef" ] =

0 commit comments

Comments
 (0)