Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion run-parts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down Expand Up @@ -93,6 +100,12 @@ dispatch_parse() {
--exit-on-error )
exit_on_error="on"
;;
--stdin)
stdin="on"
;;
--lsbsysinit)
lsbsysinit="on"
;;
--new-session )
new_session="on"
;;
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"