Make shebang check only fatal on scripts that are located in PATH, warn for those...
authorFabian Groffen <grobian@gentoo.org>
Thu, 24 Sep 2009 18:23:22 +0000 (18:23 -0000)
committerFabian Groffen <grobian@gentoo.org>
Thu, 24 Sep 2009 18:23:22 +0000 (18:23 -0000)
svn path=/main/branches/prefix/; revision=14410

bin/misc-functions.sh

index 6e5ffc2133276c2800f99c221edf44dda0cb67ac..ff6070fed14d681f28cd4d4b8a6e838ad2a8877c 100644 (file)
@@ -487,9 +487,9 @@ install_qa_check() {
                                | xargs -0 grep -H -n -m1 "^#!" \
                                | while read f ;
                do
-                       fn=${f%%:*}
-                       pos=${f#*:} ; pos=${pos%:*}
-                       line=${f##*:}
+                       local fn=${f%%:*}
+                       local pos=${f#*:} ; pos=${pos%:*}
+                       local line=${f##*:}
                        # shebang always appears on the first line ;)
                        [[ ${pos} != 1 ]] && continue
                        line=( ${line#"#!"} )
@@ -502,8 +502,11 @@ install_qa_check() {
                                sed -i -e '1s:^#1 \?:#!'"${EPREFIX}"':' "${fn}"
                                continue
                        fi
-                       # all else is an error
-                       echo "${fn#${D}}:${line[0]}" >> "${T}"/non-prefix-shebangs-errs
+                       # all else is an error if the found script is in $PATH
+                       local fp=${fn#${D}} ; fp=${fp%/*}
+                       [[ ":${PATH}:" == *":${fp}:"* || hasq stricter ${FEATURES} ]] \
+                               && echo "${fn#${D}}:${line[0]}" >> "${T}"/non-prefix-shebangs-errs \
+                               || eqawarn "invalid shebang in ${fn#${D}}: ${line[0]}"
                done
                if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then
                        eqawarn "QA Notice: the following files use invalid (possible non-prefixed) shebangs:"