diff options
author | Ulrich Müller <ulm@gentoo.org> | 2015-01-18 22:59:52 +0100 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2015-01-18 22:59:52 +0100 |
commit | ea8d129841a767d4725c513531b087f8325103bb (patch) | |
tree | 355614d7592f261e6b2bc45a970b01399e34544f /modules | |
parent | Use "git describe --long" in configure. (diff) | |
download | eselect-ea8d129841a767d4725c513531b087f8325103bb.tar.gz eselect-ea8d129841a767d4725c513531b087f8325103bb.tar.bz2 eselect-ea8d129841a767d4725c513531b087f8325103bb.zip |
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.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/rc.eselect | 11 |
1 files changed, 6 insertions, 5 deletions
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 |