commit: ea8d129841a767d4725c513531b087f8325103bb Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Sun Jan 18 21:59:52 2015 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Sun Jan 18 21:59:52 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=ea8d1298
Improve is_script test in rc module. * modules/rc.eselect (is_script): Don't call external programs. Test if script is executable, with a shebang in its first line. --- ChangeLog | 3 +++ modules/rc.eselect | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22cab2a..e8d41ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2015-01-18 Ulrich Müller <u...@gentoo.org> + * modules/rc.eselect (is_script): Don't call external programs. + Test if script is executable, with a shebang in its first line. + * configure.ac (EXTRAVERSION): Use "git describe --long". 2015-01-17 Ulrich Müller <u...@gentoo.org> diff --git a/modules/rc.eselect b/modules/rc.eselect index 2a9bf5b..c568a13 100644 --- a/modules/rc.eselect +++ b/modules/rc.eselect @@ -32,12 +32,13 @@ list_runlevels() { # is_script PRIVATE # check if file $1 is a valid init script is_script() { - local file=${1} + local file=$1 line [[ -n ${file} \ - && ${file%%.sh} = ${file} \ - && ${file%%\~} = ${file} \ - && -e ${file} ]] \ - && grep '^#!.*/\(runscript\|openrc-run\)' "${file}" &>/dev/null + && ${file%%.sh} = "${file}" \ + && ${file%%\~} = "${file}" \ + && -x ${file} ]] \ + && read line <"${file}" \ + && [[ ${line} =~ ^#!.*(runscript|openrc-run) ]] } # find_scripts PRIVATE