Use head instead of reimplementing it

Normally I wouldn't use head, but this code is partial anyway.
This commit is contained in:
Joseph C. Sible 2020-02-09 20:12:57 -05:00
parent 7e6a556ef1
commit 0ca50159ec
1 changed files with 2 additions and 4 deletions

View File

@ -565,10 +565,8 @@ checkShebang params (T_Script _ (T_Literal id sb) _) = execWriter $ do
unless (null sb) $ do unless (null sb) $ do
unless ("/" `isPrefixOf` sb) $ unless ("/" `isPrefixOf` sb) $
err id 2239 "Ensure the shebang uses an absolute path to the interpreter." err id 2239 "Ensure the shebang uses an absolute path to the interpreter."
case words sb of when ("/" `isSuffixOf` head (words sb)) $
first:_ -> err id 2246 "This shebang specifies a directory. Ensure the interpreter is a file."
when ("/" `isSuffixOf` first) $
err id 2246 "This shebang specifies a directory. Ensure the interpreter is a file."
prop_checkForInQuoted = verify checkForInQuoted "for f in \"$(ls)\"; do echo foo; done" prop_checkForInQuoted = verify checkForInQuoted "for f in \"$(ls)\"; do echo foo; done"