mirror of
				https://github.com/koalaman/shellcheck.git
				synced 2025-11-04 18:28:23 +08:00 
			
		
		
		
	Warn about ineffectual quotes in a="/foo/'bar baz'"; $a
This commit is contained in:
		@@ -2166,6 +2166,7 @@ prop_checkQuotesInLiterals5 = verifyNotTree checkQuotesInLiterals "param=\"--foo
 | 
			
		||||
prop_checkQuotesInLiterals6 = verifyTree checkQuotesInLiterals "param='my\\ file'; cmd=\"rm $param\"; $cmd"
 | 
			
		||||
prop_checkQuotesInLiterals6a= verifyNotTree checkQuotesInLiterals "param='my\\ file'; cmd=\"rm ${#param}\"; $cmd"
 | 
			
		||||
prop_checkQuotesInLiterals7 = verifyTree checkQuotesInLiterals "param='my\\ file'; rm $param"
 | 
			
		||||
prop_checkQuotesInLiterals8 = verifyTree checkQuotesInLiterals "param=\"/foo/'bar baz'/etc\"; rm $param"
 | 
			
		||||
checkQuotesInLiterals params t =
 | 
			
		||||
    doVariableFlowAnalysis readF writeF Map.empty (variableFlow params)
 | 
			
		||||
  where
 | 
			
		||||
@@ -2173,7 +2174,7 @@ checkQuotesInLiterals params t =
 | 
			
		||||
    setQuotes name ref = modify $ Map.insert name ref
 | 
			
		||||
    deleteQuotes = modify . Map.delete
 | 
			
		||||
    parents = parentMap params
 | 
			
		||||
    quoteRegex = mkRegex "\"|([= ]|^)'|'( |$)|\\\\ "
 | 
			
		||||
    quoteRegex = mkRegex "\"|([/= ]|^)'|'( |$)|\\\\ "
 | 
			
		||||
    containsQuotes s = s `matches` quoteRegex
 | 
			
		||||
 | 
			
		||||
    writeF _ _ name (DataFrom values) = do
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user