Files
finit/test/option-lookalike.sh
T
Joachim Wiberg 66b62cbd45 service: don't take a command named like an option for one
A run/task/service whose command starts like an option without a ':'
lost its command, e.g. the example in finit.conf(5):

    run [2345] @joe:users logger "Hello world"

was registered as the log option, running "Hello world".  Same for
pidof, pidproxy, and cgroupfs-mount.

The option parser matches with MATCH_CMD(), a prefix match, also for
the options with no trailing ':' to end the prefix: log, pid, cgroup,
respawn, nowarn, and the rest.

Match these against the whole token, allowing only the separator that
starts a value: "log:", "pid:", "cgroup." and "cgroup:".

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
(cherry picked from commit f15e95d1cc)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-11-17 08:01:11 +01:00

22 lines
549 B
Bash
Executable File

#!/bin/sh
# Verify that a command which starts like a service option, e.g. pidof
# vs. pid, is still taken as the command.
set -eu
TEST_DIR=$(dirname "$0")
test_teardown()
{
say "Running test teardown."
run "rm -f $FINIT_CONF"
}
# shellcheck source=/dev/null
. "$TEST_DIR/lib/setup.sh"
say 'A command named like an option is the command'
run "echo 'task [2345] name:lookalike pidof serv -- Lookalike' > $FINIT_CONF"
run "initctl reload"
retry "test \"\$(texec initctl -p status lookalike | sed -n 's/.*Command : //p')\" = 'pidof serv'"