tmpfiles: only take a # at the start of a line as a comment

An entry with a # in the argument loses it and the rest of the line:

    f /tmp/file - - - - a#b c

gives a file holding "a".  The lines are read with fparseln(), which
by default takes a # anywhere in a line as the start of a comment.  In
tmpfiles.d(5) only a line that starts with # is a comment.

Read the lines without a comment character and skip the lines that
start with one.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-21 17:13:53 +01:00
1 parent 7ec4376eb0
commit 309844fc11
3 files changed
+13 -3

No files matched your search

+5 -1
View File
@@ -66,9 +66,13 @@ assert "First match" "$(texec cat $DIR/w1 | tr '\n' ' ')" = "one two"
assert "Second match" "$(texec cat $DIR/w2 | tr '\n' ' ')" = "one two"
sep
say 'Escapes in the argument'
say 'Escapes, and a # that is not at the start of the line'
run "cat > $CONF" <<'CONF'
# A comment
# and one more
f /tmp/arg/hex - - - - \x39\x41\x4a\x6b
f /tmp/arg/hash - - - - a#b c
CONF
run "/libexec/finit/tmpfiles --create $CONF"
assert "All hex digits" "$(texec cat $DIR/hex)" = "9AJk"
assert "No comment in line" "$(texec cat $DIR/hash)" = "a#b c"