From 025b779a30476dd2b6ba9851e4ef1d57812b97c7 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 22 Sep 2016 09:43:47 +0200 Subject: Fix sbang for perl (#1802) * Perform shebang fix for all files * Fix sbang for perl scripts Otherwise perl would look at the #! line and call sbang again, resulting in an infinite loop. --- lib/spack/spack/hooks/sbang.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/hooks/sbang.py b/lib/spack/spack/hooks/sbang.py index 02c1ce3816..6f9736a018 100644 --- a/lib/spack/spack/hooks/sbang.py +++ b/lib/spack/spack/hooks/sbang.py @@ -81,8 +81,10 @@ def filter_shebang(path): tty.warn("Patched overlong shebang in %s" % path) -def filter_shebangs_in_directory(directory): - for file in os.listdir(directory): +def filter_shebangs_in_directory(directory, filenames=None): + if filenames is None: + filenames = os.listdir(directory) + for file in filenames: path = os.path.join(directory, file) # only handle files @@ -104,6 +106,6 @@ def post_install(pkg): """This hook edits scripts so that they call /bin/bash $spack_prefix/bin/sbang instead of something longer than the shebang limit.""" - if not os.path.isdir(pkg.prefix.bin): - return - filter_shebangs_in_directory(pkg.prefix.bin) + + for directory, _, filenames in os.walk(pkg.prefix): + filter_shebangs_in_directory(directory, filenames) -- cgit v1.2.3-70-g09d2