Simplified PS1 checks.
This commit is contained in:
parent
636c6a9336
commit
3832ca9d5c
|
@ -1082,24 +1082,18 @@ prop_checkPS15 = verifyNot checkPS1Assignments "PS1='\\[\\033[1;35m\\]\\$ '"
|
||||||
prop_checkPS16 = verifyNot checkPS1Assignments "PS1='\\[\\e1m\\e[1m\\]\\$ '"
|
prop_checkPS16 = verifyNot checkPS1Assignments "PS1='\\[\\e1m\\e[1m\\]\\$ '"
|
||||||
prop_checkPS17 = verifyNot checkPS1Assignments "PS1='e033x1B'"
|
prop_checkPS17 = verifyNot checkPS1Assignments "PS1='e033x1B'"
|
||||||
prop_checkPS18 = verifyNot checkPS1Assignments "PS1='\\[\\e\\]'"
|
prop_checkPS18 = verifyNot checkPS1Assignments "PS1='\\[\\e\\]'"
|
||||||
checkPS1Assignments t =
|
checkPS1Assignments (T_Assignment _ "PS1" word) = warnFor word
|
||||||
case t of
|
|
||||||
(T_Assignment _ "PS1" word) -> warnFor [word]
|
|
||||||
(T_SimpleCommand id _ tokens) ->
|
|
||||||
when (t `isCommand` "export") $
|
|
||||||
warnFor (filter isPS1Token tokens)
|
|
||||||
_ -> return ()
|
|
||||||
where
|
where
|
||||||
isPS1Token t = "PS1" `isPrefixOf` (concat $ deadSimple t)
|
warnFor word =
|
||||||
warnFor words =
|
let contents = concat $ deadSimple word in
|
||||||
let contents = concat $ concatMap deadSimple words in
|
when (containsUnescaped contents) $
|
||||||
when (not (null words) && containsUnescaped contents) $
|
info (getId word) "Make sure all escape sequences are enclosed in \\[..\\] to prevent line wrapping issues"
|
||||||
info (getId $ head words) "Make sure all escape sequences are enclosed in \\[..\\] to prevent line wrapping issues"
|
|
||||||
containsUnescaped s =
|
containsUnescaped s =
|
||||||
let unenclosed = subRegex enclosedRegex s "" in
|
let unenclosed = subRegex enclosedRegex s "" in
|
||||||
isJust $ matchRegex escapeRegex unenclosed
|
isJust $ matchRegex escapeRegex unenclosed
|
||||||
enclosedRegex = mkRegex "\\\\\\[.*\\\\\\]" -- FIXME: shouldn't be eager
|
enclosedRegex = mkRegex "\\\\\\[.*\\\\\\]" -- FIXME: shouldn't be eager
|
||||||
escapeRegex = mkRegex "\\\\x1[Bb]|\\\\e|\x1B|\\\\033"
|
escapeRegex = mkRegex "\\\\x1[Bb]|\\\\e|\x1B|\\\\033"
|
||||||
|
checkPS1Assignments _ = return ()
|
||||||
|
|
||||||
prop_checkBackticks1 = verify checkBackticks "echo `foo`"
|
prop_checkBackticks1 = verify checkBackticks "echo `foo`"
|
||||||
prop_checkBackticks2 = verifyNot checkBackticks "echo $(foo)"
|
prop_checkBackticks2 = verifyNot checkBackticks "echo $(foo)"
|
||||||
|
|
Loading…
Reference in New Issue