mirror of
				https://github.com/koalaman/shellcheck.git
				synced 2025-11-04 18:28:23 +08:00 
			
		
		
		
	Don't warn about tr '[=e=]' equivalence classes
This commit is contained in:
		@@ -3,6 +3,7 @@
 | 
				
			|||||||
### Changed
 | 
					### Changed
 | 
				
			||||||
- Most warnings now have useful end positions
 | 
					- Most warnings now have useful end positions
 | 
				
			||||||
### Fixed
 | 
					### Fixed
 | 
				
			||||||
 | 
					- SC2021 no longer triggers for equivalence classes like '[=e=]'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## v0.5.0 - 2018-05-31
 | 
					## v0.5.0 - 2018-05-31
 | 
				
			||||||
### Added
 | 
					### Added
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -141,6 +141,7 @@ prop_checkTr8 = verifyNot checkTr "tr aeiou _____"
 | 
				
			|||||||
prop_checkTr9 = verifyNot checkTr "a-z n-za-m"
 | 
					prop_checkTr9 = verifyNot checkTr "a-z n-za-m"
 | 
				
			||||||
prop_checkTr10= verifyNot checkTr "tr --squeeze-repeats rl lr"
 | 
					prop_checkTr10= verifyNot checkTr "tr --squeeze-repeats rl lr"
 | 
				
			||||||
prop_checkTr11= verifyNot checkTr "tr abc '[d*]'"
 | 
					prop_checkTr11= verifyNot checkTr "tr abc '[d*]'"
 | 
				
			||||||
 | 
					prop_checkTr12= verifyNot checkTr "tr '[=e=]' 'e'"
 | 
				
			||||||
checkTr = CommandCheck (Basename "tr") (mapM_ f . arguments)
 | 
					checkTr = CommandCheck (Basename "tr") (mapM_ f . arguments)
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
    f w | isGlob w = -- The user will go [ab] -> '[ab]' -> 'ab'. Fixme?
 | 
					    f w | isGlob w = -- The user will go [ab] -> '[ab]' -> 'ab'. Fixme?
 | 
				
			||||||
@@ -152,7 +153,7 @@ checkTr = CommandCheck (Basename "tr") (mapM_ f . arguments)
 | 
				
			|||||||
        Just s -> do  -- Eliminate false positives by only looking for dupes in SET2?
 | 
					        Just s -> do  -- Eliminate false positives by only looking for dupes in SET2?
 | 
				
			||||||
          when (not ("-" `isPrefixOf` s || "[:" `isInfixOf` s) && duplicated s) $
 | 
					          when (not ("-" `isPrefixOf` s || "[:" `isInfixOf` s) && duplicated s) $
 | 
				
			||||||
            info (getId word) 2020 "tr replaces sets of chars, not words (mentioned due to duplicates)."
 | 
					            info (getId word) 2020 "tr replaces sets of chars, not words (mentioned due to duplicates)."
 | 
				
			||||||
          unless ("[:" `isPrefixOf` s) $
 | 
					          unless ("[:" `isPrefixOf` s || "[=" `isPrefixOf` s) $
 | 
				
			||||||
            when ("[" `isPrefixOf` s && "]" `isSuffixOf` s && (length s > 2) && ('*' `notElem` s)) $
 | 
					            when ("[" `isPrefixOf` s && "]" `isSuffixOf` s && (length s > 2) && ('*' `notElem` s)) $
 | 
				
			||||||
              info (getId word) 2021 "Don't use [] around classes in tr, it replaces literal square brackets."
 | 
					              info (getId word) 2021 "Don't use [] around classes in tr, it replaces literal square brackets."
 | 
				
			||||||
        Nothing -> return ()
 | 
					        Nothing -> return ()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user