-
-
Save disassembler/1e674157f8b02e8e2a7fd502ee0c2231 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git i/src/ShellCheck/Analytics.hs w/src/ShellCheck/Analytics.hs | |
| index b094acf..18adff4 100644 | |
| --- i/src/ShellCheck/Analytics.hs | |
| +++ w/src/ShellCheck/Analytics.hs | |
| @@ -417,9 +417,10 @@ indexOfSublists sub = f 0 | |
| prop_checkShebangParameters1 = verifyTree checkShebangParameters "#!/usr/bin/env bash -x\necho cow" | |
| prop_checkShebangParameters2 = verifyNotTree checkShebangParameters "#! /bin/sh -l " | |
| +prop_checkShebangParameters3 = verifyTree checkShebangParameters "#!/usr/bin/env nix-shell\n#!nix-shell -i bash -p coreutils jq\necho cow" | |
| checkShebangParameters p (T_Annotation _ _ t) = checkShebangParameters p t | |
| checkShebangParameters _ (T_Script id sb _) = | |
| - [makeComment ErrorC id 2096 "On most OS, shebangs can only specify a single parameter." | length (words sb) > 2] | |
| + [makeComment ErrorC id 2096 "On most OS, shebangs can only specify a single parameter." | ((length (words sb) > 2) && ((head (words sb)) /= "nix-shell"))] | |
| prop_checkShebang1 = verifyNotTree checkShebang "#!/usr/bin/env bash -x\necho cow" | |
| prop_checkShebang2 = verifyNotTree checkShebang "#! /bin/sh -l " | |
| @@ -428,6 +429,7 @@ prop_checkShebang4 = verifyNotTree checkShebang "#shellcheck shell=sh\nfoo" | |
| prop_checkShebang5 = verifyTree checkShebang "#!/usr/bin/env ash" | |
| prop_checkShebang6 = verifyNotTree checkShebang "#!/usr/bin/env ash\n# shellcheck shell=dash\n" | |
| prop_checkShebang7 = verifyNotTree checkShebang "#!/usr/bin/env ash\n# shellcheck shell=sh\n" | |
| +prop_checkShebang8 = verifyTree checkShebang "#!/usr/bin/env nix-shell\n#!nix-shell -i bash -p coreutils jq\necho cow" | |
| checkShebang params (T_Annotation _ list t) = | |
| if any isOverride list then [] else checkShebang params t | |
| where | |
| diff --git i/src/ShellCheck/Parser.hs w/src/ShellCheck/Parser.hs | |
| index 84b80dc..10ab5d7 100644 | |
| --- i/src/ShellCheck/Parser.hs | |
| +++ w/src/ShellCheck/Parser.hs | |
| @@ -2672,6 +2672,8 @@ prop_readShebang4 = isWarning readShebang "! /bin/sh" | |
| prop_readShebang5 = isWarning readShebang "\n#!/bin/sh" | |
| prop_readShebang6 = isWarning readShebang " # Copyright \n!#/bin/bash" | |
| prop_readShebang7 = isNotOk readShebang "# Copyright \nfoo\n#!/bin/bash" | |
| +prop_readShebang8 = isOk readShebang "#!/usr/bin/env nix-shell\n#!nix-shell -i bash -p coreutils\n" | |
| +--prop_readShebang8 = isNotOk readShebang "#!/usr/bin/env nix-shell\n#!nix-shell -i awk -p coreutils\n" | |
| readShebang = do | |
| anyShebang <|> try readMissingBang <|> withHeader | |
| many linewhitespace | |
| @@ -2786,6 +2788,11 @@ readScriptFile = do | |
| case words sb of | |
| [] -> "" | |
| [x] -> basename x | |
| + (first:second:third:_) -> | |
| + case basename first of | |
| + "env" -> second | |
| + "nix-shell" -> third | |
| + _ -> basename first | |
| (first:second:_) -> | |
| if basename first == "env" | |
| then second | |
| @@ -2795,7 +2802,8 @@ readScriptFile = do | |
| case isValidShell s of | |
| Just True -> return () | |
| Just False -> parseProblemAt pos ErrorC 1071 "ShellCheck only supports sh/bash/dash/ksh scripts. Sorry!" | |
| - Nothing -> parseProblemAt pos InfoC 1008 "This shebang was unrecognized. Note that ShellCheck only handles sh/bash/dash/ksh." | |
| + --Nothing -> parseProblemAt pos InfoC 1008 "This shebang was unrecognized. Note that ShellCheck only handles sh/bash/dash/ksh." | |
| + Nothing -> parseProblemAt pos InfoC 1008 s | |
| isValidShell s = | |
| let good = s == "" || any (`isPrefixOf` s) goodShells |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment