mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-09-23 04:19:45 +08:00
Simplify shellFromFilename
This commit is contained in:
@@ -48,7 +48,7 @@ tokenToPosition startMap t = fromMaybe fail $ do
|
|||||||
where
|
where
|
||||||
fail = error "Internal shellcheck error: id doesn't exist. Please report!"
|
fail = error "Internal shellcheck error: id doesn't exist. Please report!"
|
||||||
|
|
||||||
shellFromFilename filename = foldl mplus Nothing candidates
|
shellFromFilename filename = listToMaybe candidates
|
||||||
where
|
where
|
||||||
shellExtensions = [(".ksh", Ksh)
|
shellExtensions = [(".ksh", Ksh)
|
||||||
,(".bash", Bash)
|
,(".bash", Bash)
|
||||||
@@ -57,7 +57,7 @@ shellFromFilename filename = foldl mplus Nothing candidates
|
|||||||
-- The `.sh` is too generic to determine the shell:
|
-- The `.sh` is too generic to determine the shell:
|
||||||
-- We fallback to Bash in this case and emit SC2148 if there is no shebang
|
-- We fallback to Bash in this case and emit SC2148 if there is no shebang
|
||||||
candidates =
|
candidates =
|
||||||
map (\(ext,sh) -> if ext `isSuffixOf` filename then Just sh else Nothing) shellExtensions
|
[sh | (ext,sh) <- shellExtensions, ext `isSuffixOf` filename]
|
||||||
|
|
||||||
checkScript :: Monad m => SystemInterface m -> CheckSpec -> m CheckResult
|
checkScript :: Monad m => SystemInterface m -> CheckSpec -> m CheckResult
|
||||||
checkScript sys spec = do
|
checkScript sys spec = do
|
||||||
|
Reference in New Issue
Block a user