Fixed broken recursive backtick expansion.
This commit is contained in:
parent
8055b6f9c5
commit
d04262c70f
|
@ -281,6 +281,7 @@ checkUuoc (T_Pipeline _ ((T_Redirecting _ _ cmd):_:_)) = checkCommand "cat" f cm
|
||||||
checkUuoc _ = return ()
|
checkUuoc _ = return ()
|
||||||
|
|
||||||
prop_checkNeedlessCommands = verify checkNeedlessCommands "foo=$(expr 3 + 2)"
|
prop_checkNeedlessCommands = verify checkNeedlessCommands "foo=$(expr 3 + 2)"
|
||||||
|
prop_checkNeedlessCommands2 = verify checkNeedlessCommands "foo=`echo \\`expr 3 + 2\\``"
|
||||||
checkNeedlessCommands (T_SimpleCommand id _ (w:_)) | w `isCommand` "expr" =
|
checkNeedlessCommands (T_SimpleCommand id _ (w:_)) | w `isCommand` "expr" =
|
||||||
style id "Use $((..)), ${} or [[ ]] in place of antiquated expr."
|
style id "Use $((..)), ${} or [[ ]] in place of antiquated expr."
|
||||||
checkNeedlessCommands (T_SimpleCommand id _ (w:_)) | w `isCommand` "dirname" =
|
checkNeedlessCommands (T_SimpleCommand id _ (w:_)) | w `isCommand` "dirname" =
|
||||||
|
|
|
@ -672,7 +672,7 @@ readBackTicked = called "backtick expansion" $ do
|
||||||
subStart <- getPosition
|
subStart <- getPosition
|
||||||
subString <- readGenericLiteral (char '`')
|
subString <- readGenericLiteral (char '`')
|
||||||
char '`'
|
char '`'
|
||||||
result <- subParse subStart readCompoundList subString
|
result <- subParse subStart readCompoundList (unEscape subString)
|
||||||
return $ T_Backticked id result
|
return $ T_Backticked id result
|
||||||
where
|
where
|
||||||
-- Position may be off due to escapes
|
-- Position may be off due to escapes
|
||||||
|
@ -685,6 +685,11 @@ readBackTicked = called "backtick expansion" $ do
|
||||||
setInput lastInput
|
setInput lastInput
|
||||||
setPosition lastPosition
|
setPosition lastPosition
|
||||||
return result
|
return result
|
||||||
|
unEscape [] = []
|
||||||
|
unEscape ('\\':x:rest) | x `elem` "\"$`\\" = x : unEscape rest
|
||||||
|
unEscape ('\\':'\n':rest) = unEscape rest
|
||||||
|
unEscape (c:rest) = c : unEscape rest
|
||||||
|
|
||||||
|
|
||||||
prop_readDoubleQuoted = isOk readDoubleQuoted "\"Hello $FOO\""
|
prop_readDoubleQuoted = isOk readDoubleQuoted "\"Hello $FOO\""
|
||||||
readDoubleQuoted = called "double quoted string" $ do
|
readDoubleQuoted = called "double quoted string" $ do
|
||||||
|
|
Loading…
Reference in New Issue