Skip to content

Commit

Permalink
Ignore leading \ for commands (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
koalaman committed Jul 3, 2017
1 parent 5bd33db commit 31bb02d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ShellCheck/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
yOU should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-}
{-# LANGUAGE NoMonomorphismRestriction, TemplateHaskell, FlexibleContexts #-}
Expand Down Expand Up @@ -1799,6 +1799,7 @@ prop_readSimpleCommand3 = isOk readSimpleCommand "export foo=(bar baz)"
prop_readSimpleCommand4 = isOk readSimpleCommand "typeset -a foo=(lol)"
prop_readSimpleCommand5 = isOk readSimpleCommand "time if true; then echo foo; fi"
prop_readSimpleCommand6 = isOk readSimpleCommand "time -p ( ls -l; )"
prop_readSimpleCommand7 = isOk readSimpleCommand "\\ls"
readSimpleCommand = called "simple command" $ do
pos <- getPosition
id1 <- getNextId
Expand Down Expand Up @@ -1968,7 +1969,12 @@ readCommand = choice [
readSimpleCommand
]

readCmdName = readCmdWord
readCmdName = do
-- Ignore alias suppression
optional . try $ do
char '\\'
lookAhead $ variableChars
readCmdWord
readCmdWord = readNormalWord <* spacing

prop_readIfClause = isOk readIfClause "if false; then foo; elif true; then stuff; more stuff; else cows; fi"
Expand Down

0 comments on commit 31bb02d

Please sign in to comment.