From 7709931085230499a594ff47760fd9d41f603839 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 23 Dec 2011 20:23:29 +0100 Subject: [PATCH] Fix detection of interpreters. --- tools/find-requires | 2 +- tools/functions-files | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/find-requires b/tools/find-requires index c65a894da..8bb6fb984 100755 --- a/tools/find-requires +++ b/tools/find-requires @@ -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. diff --git a/tools/functions-files b/tools/functions-files index b35439d3e..ab0ba34a7 100644 --- a/tools/functions-files +++ b/tools/functions-files @@ -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 -- 2.39.5