diff --git a/run-parts.sh b/run-parts.sh index aaf0ae8..75e73eb 100755 --- a/run-parts.sh +++ b/run-parts.sh @@ -2,10 +2,11 @@ set -eu COMMAND="${0}" -VERSION="0.2pre" +VERSION="0.3pre" DEFAULT_REGEX='^[a-zA-Z0-9_\.-]+$' LANANA_REGEX='^[a-z0-9]+$' +LSB_REGEX='^(([a-z0-9]+)|(_?([a-z0-9_.]+-)+[a-z0-9]+)|([a-zA-Z0-9_-]+))$' # One of "run", "list", and "report" mode="run" @@ -18,9 +19,15 @@ umask="022" dir="" args="" +stdin="off" +lsbsysinit="off" + # Starts with a comma to ease searching ignore_suffixes=",.rpmsave,.rpmorig,.rpmnew,.swp,.cfsaved," +# Suffixes to ignore in lsb mode +lsb_ignore_suffixes=",.dpkg-old,.dpkg-new,.dpkg-tmp,.dpkg-dist,.rpmsave,.rpmorig,.rpmnew,.swp,.cfsaved," + # One of "run", "directory", "umask", "regex", "arg", "suffixes", or "done" parsemode="run" @@ -93,6 +100,12 @@ dispatch_parse() { --exit-on-error ) exit_on_error="on" ;; + --stdin) + stdin="on" + ;; + --lsbsysinit) + lsbsysinit="on" + ;; --new-session ) new_session="on" ;; @@ -201,6 +214,15 @@ if [ ! -d "${dir}" ] || [ ! -x "${dir}" ]; then exit 1 fi +if [ ${stdin} = "on" ]; then + echo "WARNING: Option --stdin is not yet implemented. Ignoring." +fi + +if [ ${lsbsysinit} = "on" ]; then + regex="${LSB_REGEX}" + ignore_suffixes="${lsb_ignore_suffixes}" +fi + umask "${umask}" for file in ${dir}/*; do diff --git a/test.sh b/test.sh index 0ec2ea4..2d67e4f 100755 --- a/test.sh +++ b/test.sh @@ -53,3 +53,18 @@ rm tests/empty/* 2>/dev/null || true val="$(${SH} run-parts.sh --list --regex="" -- tests/empty)" assert_eq "${val}" "" rmdir tests/empty + +# Test --lsbsysinit +rm -rf tests/lsb || true +mkdir tests/lsb || true +for name in "good" "invalid1.dpkg-new" "Good.2.Not" "invalid+symbol" "10-very-good" "10-ALSO-GOOD" +do + touch "tests/lsb/${name}" + chmod 755 "tests/lsb/${name}" +done +val="$(${SH} run-parts.sh --lsbsysinit --test ./tests/lsb | sort)" +rm -rf tests/lsb || true + +assert_eq "${val}" "10-ALSO-GOOD +10-very-good +good"