Adds support for a SHELLCHECK_OPTS environment variable.

This commit is contained in:
Vidar Holen
2015-08-22 13:15:10 -07:00
parent d0029ae1d4
commit ae4aea4530
3 changed files with 25 additions and 1 deletions

View File

@@ -20,6 +20,7 @@
import ShellCheck.Data
import ShellCheck.Checker
import ShellCheck.Interface
import ShellCheck.Regex
import ShellCheck.Formatter.Format
import qualified ShellCheck.Formatter.CheckStyle
@@ -123,8 +124,17 @@ getExclusions options =
toStatus = liftM (either id id) . runExceptT
getEnvArgs = do
opts <- getEnv "SHELLCHECK_OPTS" `catch` cantWaitForLookupEnv
return . filter (not . null) $ opts `splitOn` mkRegex " +"
where
cantWaitForLookupEnv :: IOException -> IO String
cantWaitForLookupEnv = const $ return ""
main = do
args <- getArgs
params <- getArgs
envOpts <- getEnvArgs
let args = envOpts ++ params
status <- toStatus $ do
(flags, files) <- parseArguments args
process flags files