diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-04-15 19:36:11 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-04-15 19:36:11 +0200 |
commit | b493a9be142e15ebd1cb32c61b0fd2ac39b703c3 (patch) | |
tree | 4b81da5440c4a76bb600ea687c5a033d0f72c978 /src | |
parent | 35a266603a6ce48aecc4e35cc929772dc299ed04 (diff) |
Avoid head usage in Main
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Main.hs b/src/Main.hs index dbdbb40..e69c672 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -133,9 +133,11 @@ main = do putStrLn versionLine exitSuccess - getPermissions (head $ words $ optDefaultTool $ optTest opts) >>= \perms -> do - when (not $ executable perms) $ do - fail $ optDefaultTool (optTest opts) <> " is not executable" + case words $ optDefaultTool $ optTest opts of + (path : _) -> getPermissions path >>= \perms -> do + when (not $ executable perms) $ do + fail $ "‘" <> path <> "’ is not executable" + _ -> fail $ "invalid tool argument: ‘" <> optDefaultTool (optTest opts) <> "’" files <- if not (null ofiles) then return $ flip map ofiles $ \ofile -> |