Commit 16de5ac6 authored by Kevin Daudt's avatar Kevin Daudt

initd-lint: prevent false positive for start_pre

start_pre is perfectly fine to have in an init script, but initd-lint
accidentally flagged it as a custom `stop` function.

Tighten the match for custom start/stop function to prevent false
positives.
parent 40894060
Pipeline #1986 passed with stage
in 28 seconds
......@@ -22,7 +22,7 @@ unexpected_shebang_line() {
}
custom_start_stop_function() {
scan '(start|stop)\s*\(\)\s*\{' "Don't define a custom start\/stop function" 'AL34' 'IC'
scan '\b(start|stop)\s*\(\)\s*\{' "Don't define a custom start\/stop function" 'AL34' 'IC'
}
_ret=0
......
......@@ -64,3 +64,17 @@ assert_match() {
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "custom start/stop function"
}
@test "should not warn about pre_start" {
cat <<-"EOF" >$service
#!/sbin/openrc-run
pre_start() {
start_command
}
EOF
run $cmd $service
[[ $status -eq 0 ]]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment