Skip to content

Commit 31bb02d

Browse files
committed
Ignore leading \ for commands (#927)
1 parent 5bd33db commit 31bb02d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ShellCheck/Parser.hs

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
GNU General Public License for more details.
1616
17-
yOU should have received a copy of the GNU General Public License
17+
You should have received a copy of the GNU General Public License
1818
along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
-}
2020
{-# LANGUAGE NoMonomorphismRestriction, TemplateHaskell, FlexibleContexts #-}
@@ -1799,6 +1799,7 @@ prop_readSimpleCommand3 = isOk readSimpleCommand "export foo=(bar baz)"
17991799
prop_readSimpleCommand4 = isOk readSimpleCommand "typeset -a foo=(lol)"
18001800
prop_readSimpleCommand5 = isOk readSimpleCommand "time if true; then echo foo; fi"
18011801
prop_readSimpleCommand6 = isOk readSimpleCommand "time -p ( ls -l; )"
1802+
prop_readSimpleCommand7 = isOk readSimpleCommand "\\ls"
18021803
readSimpleCommand = called "simple command" $ do
18031804
pos <- getPosition
18041805
id1 <- getNextId
@@ -1968,7 +1969,12 @@ readCommand = choice [
19681969
readSimpleCommand
19691970
]
19701971

1971-
readCmdName = readCmdWord
1972+
readCmdName = do
1973+
-- Ignore alias suppression
1974+
optional . try $ do
1975+
char '\\'
1976+
lookAhead $ variableChars
1977+
readCmdWord
19721978
readCmdWord = readNormalWord <* spacing
19731979

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

0 commit comments

Comments
 (0)