mirror of
				https://github.com/koalaman/shellcheck.git
				synced 2025-11-04 09:26:10 +08:00 
			
		
		
		
	Don't warn for $ on $(( ${array[refs]} ))
This commit is contained in:
		@@ -752,11 +752,12 @@ prop_checkArithmeticDeref2 = verify checkArithmeticDeref "cow=14; (( s+= $cow ))
 | 
				
			|||||||
prop_checkArithmeticDeref3 = verifyNot checkArithmeticDeref "cow=1/40; (( s+= ${cow%%/*} ))"
 | 
					prop_checkArithmeticDeref3 = verifyNot checkArithmeticDeref "cow=1/40; (( s+= ${cow%%/*} ))"
 | 
				
			||||||
prop_checkArithmeticDeref4 = verifyNot checkArithmeticDeref "(( ! $? ))"
 | 
					prop_checkArithmeticDeref4 = verifyNot checkArithmeticDeref "(( ! $? ))"
 | 
				
			||||||
prop_checkArithmeticDeref5 = verifyNot checkArithmeticDeref "(($1))"
 | 
					prop_checkArithmeticDeref5 = verifyNot checkArithmeticDeref "(($1))"
 | 
				
			||||||
 | 
					prop_checkArithmeticDeref6 = verifyNot checkArithmeticDeref "(( ${a[$i]} ))"
 | 
				
			||||||
checkArithmeticDeref (TA_Expansion _ (T_DollarBraced id l)) | not . excepting $ bracedString l =
 | 
					checkArithmeticDeref (TA_Expansion _ (T_DollarBraced id l)) | not . excepting $ bracedString l =
 | 
				
			||||||
    style id $ "Don't use $ on variables in (( ))."
 | 
					    style id $ "Don't use $ on variables in (( ))."
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
    excepting [] = True
 | 
					    excepting [] = True
 | 
				
			||||||
    excepting s = (any (`elem` "/.:#%?*@") s) || (isDigit $ head s)
 | 
					    excepting s = (any (`elem` "/.:#%?*@[]") s) || (isDigit $ head s)
 | 
				
			||||||
checkArithmeticDeref _ = return ()
 | 
					checkArithmeticDeref _ = return ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
prop_checkArithmeticBadOctal1 = verify checkArithmeticBadOctal "(( 0192 ))"
 | 
					prop_checkArithmeticBadOctal1 = verify checkArithmeticBadOctal "(( 0192 ))"
 | 
				
			||||||
@@ -1450,7 +1451,7 @@ prop_checkSpacefulnessJ = verifyFull checkSpacefulness "echo $PWD"
 | 
				
			|||||||
checkSpacefulness t =
 | 
					checkSpacefulness t =
 | 
				
			||||||
    doVariableFlowAnalysis readF writeF (Map.fromList defaults) t
 | 
					    doVariableFlowAnalysis readF writeF (Map.fromList defaults) t
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
    defaults = 
 | 
					    defaults =
 | 
				
			||||||
        let values = ["PWD"] ++ (map show [0..10]) in
 | 
					        let values = ["PWD"] ++ (map show [0..10]) in
 | 
				
			||||||
            zip values (repeat True)
 | 
					            zip values (repeat True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user