diff options
Diffstat (limited to 'lib/spack/spack/hooks/sbang.py')
-rw-r--r-- | lib/spack/spack/hooks/sbang.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/spack/spack/hooks/sbang.py b/lib/spack/spack/hooks/sbang.py index 17f6ac2528..09691b3f0f 100644 --- a/lib/spack/spack/hooks/sbang.py +++ b/lib/spack/spack/hooks/sbang.py @@ -38,9 +38,12 @@ shebang_limit = 127 def shebang_too_long(path): """Detects whether a file has a shebang line that is too long.""" - with open(path, 'r') as script: + if not os.path.isfile(path): + return False + + with open(path, 'rb') as script: bytes = script.read(2) - if bytes != '#!': + if bytes != b'#!': return False line = bytes + script.readline() |