diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index 4ad3bf7..a557e3e 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -281,6 +281,7 @@ checkUuoc (T_Pipeline _ ((T_Redirecting _ _ cmd):_:_)) = checkCommand "cat" f cm checkUuoc _ = return () 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" = style id "Use $((..)), ${} or [[ ]] in place of antiquated expr." checkNeedlessCommands (T_SimpleCommand id _ (w:_)) | w `isCommand` "dirname" = diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index 58b0c1b..7577617 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -672,7 +672,7 @@ readBackTicked = called "backtick expansion" $ do subStart <- getPosition subString <- readGenericLiteral (char '`') char '`' - result <- subParse subStart readCompoundList subString + result <- subParse subStart readCompoundList (unEscape subString) return $ T_Backticked id result where -- Position may be off due to escapes @@ -685,6 +685,11 @@ readBackTicked = called "backtick expansion" $ do setInput lastInput setPosition lastPosition 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\"" readDoubleQuoted = called "double quoted string" $ do