From b000b055072eed79354424adfadcc73f9fff1494 Mon Sep 17 00:00:00 2001
From: Vidar Holen <spam@vidarholen.net>
Date: Sat, 26 Jul 2014 12:07:59 -0700
Subject: [PATCH] Parse empty and comment-only backtick expansions.

---
 ShellCheck/Parser.hs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs
index cb45a1d..2b9ba25 100644
--- a/ShellCheck/Parser.hs
+++ b/ShellCheck/Parser.hs
@@ -811,6 +811,8 @@ prop_readBackTicked3 = isWarning readBackTicked "´grep \"\\\"\"´"
 prop_readBackTicked4 = isOk readBackTicked "`echo foo\necho bar`"
 prop_readBackTicked5 = isOk readSimpleCommand "echo `foo`bar"
 prop_readBackTicked6 = isWarning readSimpleCommand "echo `foo\necho `bar"
+prop_readBackTicked7 = isOk readSimpleCommand "`#inline comment`"
+prop_readBackTicked8 = isOk readSimpleCommand "echo `#comment` \\\nbar baz"
 readBackTicked = called "backtick expansion" $ do
     id <- getNextId
     startPos <- getPosition
@@ -826,7 +828,7 @@ readBackTicked = called "backtick expansion" $ do
             suggestForgotClosingQuote startPos endPos "backtick expansion"
 
     -- Result positions may be off due to escapes
-    result <- subParse subStart readCompoundList (unEscape subString)
+    result <- subParse subStart readTermOrNone (unEscape subString)
     return $ T_Backticked id result
   where
     unEscape [] = []
@@ -1390,6 +1392,12 @@ readAndOr = do
                 then andOr
                 else T_Annotation aid annotations andOr
 
+readTermOrNone = do
+    allspacing
+    readTerm <|> do
+        eof
+        return []
+
 readTerm = do
     allspacing
     m <- readAndOr