]> git.ipfire.org Git - pakfire.git/commitdiff
Fix detection of interpreters.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 23 Dec 2011 19:23:29 +0000 (20:23 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 23 Dec 2011 19:23:29 +0000 (20:23 +0100)
tools/find-requires
tools/functions-files

index c65a894da69f8a6bfeba7fb33773c5e399e1bb80..8bb6fb984f117b76312f74664c03b797d9c2139e 100755 (executable)
@@ -82,7 +82,7 @@ interpreters=
 for file in ${script_files}; do
        [ -r ${file} -a -x ${file} ] || continue
 
-       interp=$(head -n 1 ${file} | sed -e 's/^\#\![   ]*//' | cut -d" " -f1)
+       interp=$(file_get_script_interpreter ${file})
        interpreters="${interpreters} ${interp}"
 
        # Collect all perl files.
index b35439d3ebb3453a0384a48657d41f8fd7a29681..ab0ba34a7a6887b64fe12e18d09dddcbcfb275b7 100644 (file)
@@ -62,11 +62,17 @@ function file_get_script_interpreter() {
 
        local first_line=$(head -n1 ${file})
 
+       # Return nothing if no shebang was found.
+       [ "${first_line:0:2}" = "#!" ] || return
+
        first_line="${first_line:2:${#first_line}}"
 
        # Choose the first argument and strip any parameters if available
        local interpreter
        for interpreter in ${first_line}; do
+               # Skip interpreters that do that have an absolute path.
+               [ "${interpreter:0:1}" = "/" ] || break
+
                echo "${interpreter}"
                return
        done