From 7dacb62d369c1448cc3fced4598c7fb8ea4aa1ef Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 9 Mar 2014 17:24:05 -0700 Subject: [PATCH] Fixed determining shell for shebangs with flags --- ShellCheck/Analytics.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index 7fc4869..8562a08 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -98,8 +98,10 @@ checkList l t = concatMap (\f -> f t) l prop_determineShell0 = determineShell (T_Script (Id 0) "#!/bin/sh" []) == Sh prop_determineShell1 = determineShell (T_Script (Id 0) "#!/usr/bin/env ksh" []) == Ksh prop_determineShell2 = determineShell (T_Script (Id 0) "" []) == Bash +prop_determineShell3 = determineShell (T_Script (Id 0) "#!/bin/sh -e" []) == Sh determineShell (T_Script _ shebang _) = fromMaybe Bash . shellForExecutable $ shellFor shebang where shellFor s | "/env " `isInfixOf` s = head (drop 1 (words s)++[""]) + shellFor s | ' ' `elem` s = shellFor $ takeWhile (/= ' ') s shellFor s = reverse . takeWhile (/= '/') . reverse $ s shellForExecutable "sh" = return Sh