From 947ae519a2f866d25d0c88ea9a1b43e789a3b470 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Thu, 8 Nov 2012 20:28:06 -0800 Subject: [PATCH] Fixed [ grep foo bar ] warning not working --- ShellCheck/Parser.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index b2fb2e4..7814cab 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -146,10 +146,11 @@ acceptButWarn parser level note = do ) +prop_readConditionContents = isWarning readCondition "[ grep -q file dir ]" readConditionContents single = do readCondOr `attempting` (lookAhead $ do pos <- getPosition - choice (map string commonCommands) + choice (map (try . string) commonCommands) parseProblemAt pos WarningC "To check a command, skip [] and just do 'if foo | grep bar; then'.") where @@ -264,7 +265,6 @@ readConditionContents single = do readCondOr = chainl1 readCondAnd readCondAndOp readCondAnd = chainl1 readCondTerm readCondOrOp - commonCommands :: [String] commonCommands = [ "bash", "bunzip2", "busybox", "bzcat", "bzcmp", "bzdiff", "bzegrep", "bzexe", "bzfgrep", "bzgrep", "bzip2", "bzip2recover", "bzless", "bzmore", "cat", "chacl", "chgrp", "chmod", "chown", "cp", "cpio", "dash", "date", "dd", "df", "dir", "dmesg", "dnsdomainname", "domainname", "echo", "ed", "egrep", "false", "fgconsole", "fgrep", "fuser", "getfacl", "grep", "gunzip", "gzexe", "gzip", "hostname", "ip", "kill", "ksh", "ksh93", "less", "lessecho", "lessfile", "lesskey", "lesspipe", "ln", "loadkeys", "login", "ls", "lsmod", "mkdir", "mknod", "mktemp", "more", "mount", "mountpoint", "mt", "mt-gnu", "mv", "nano", "nc", "nc.traditional", "netcat", "netstat", "nisdomainname", "noshell", "pidof", "ping", "ping6", "ps", "pwd", "rbash", "readlink", "rm", "rmdir", "rnano", "run-parts", "sed", "setfacl", "sh", "sh.distrib", "sleep", "stty", "su", "sync", "tailf", "tar", "tempfile", "touch", "true", "umount", "uname", "uncompress", "vdir", "which", "ypdomainname", "zcat", "zcmp", "zdiff", "zegrep", "zfgrep", "zforce", "zgrep", "zless", "zmore", "znew" ] readCondition = do