From d6d2dff324347dc7dab1d453ef17378c752b8a78 Mon Sep 17 00:00:00 2001 From: healther Date: Fri, 18 Aug 2017 20:57:52 +0200 Subject: sbang support: add node-js and fix lua This adds sbang hook support for node-js and fixes the sbang filter for lua (the character class exclusion was swallowing newlines and reporting a false positive if lua was mentioned anywhere in the file). --- lib/spack/spack/hooks/sbang.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/hooks/sbang.py b/lib/spack/spack/hooks/sbang.py index e86f8260b8..cd3529dbb8 100644 --- a/lib/spack/spack/hooks/sbang.py +++ b/lib/spack/spack/hooks/sbang.py @@ -62,10 +62,17 @@ def filter_shebang(path): if original.startswith(new_sbang_line): return + # In the following, newlines have to be excluded in the regular expression + # else any mention of "lua" in the document will lead to spurious matches. + # Use --! instead of #! on second line for lua. - if re.search(r'^#!(/[^/]*)*lua\b', original): + if re.search(r'^#!(/[^/\n]*)*lua\b', original): original = re.sub(r'^#', '--', original) + # Use //! instead of #! on second line for node.js. + if re.search(r'^#!(/[^/\n]*)*node\b', original): + original = re.sub(r'^#', '//', original) + # Change non-writable files to be writable if needed. saved_mode = None if not os.access(path, os.W_OK): -- cgit v1.2.3-60-g2f50