mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: read quotes and escapes in the fields before the argument
There is no way to write an entry for a path with a space in it, the
fields are split at every space. In tmpfiles.d(5) a field can be
quoted, and have C-style escapes:
d "/srv/my files"
d /srv/my\sfiles
Split the fields with a function that resolves both. The argument is
still the rest of the line as it is, quotes and all, like in systemd.
An entry with a quote left open is skipped.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
4 files changed
+92
-13
No files matched your search
@@ -86,3 +86,19 @@ 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"
|
||||
|
||||
sep
|
||||
say 'A path can be quoted, and have escapes'
|
||||
run "cat > $CONF" <<'CONF'
|
||||
f "/tmp/arg/with space" - - - - double
|
||||
f '/tmp/arg/single quote' - - - - single
|
||||
f /tmp/arg/mid"dle sp"ace - - - - middle
|
||||
f /tmp/arg/esc\x41\sped - - - - "kept as is"
|
||||
f "/tmp/arg/open - - - - quote
|
||||
CONF
|
||||
run "/libexec/finit/tmpfiles --create $CONF"
|
||||
assert "Double quotes" "$(texec cat "$DIR/with space")" = "double"
|
||||
assert "Single quotes" "$(texec cat "$DIR/single quote")" = "single"
|
||||
assert "Quotes in path" "$(texec cat "$DIR/middle space")" = "middle"
|
||||
assert "Escapes in path" "$(texec cat "$DIR/escA ped")" = '"kept as is"'
|
||||
assert "Skipped with a quote left open" "$(texec sh -c "ls $DIR | grep -c open")" = "0"
|
||||
Reference in new issue
Block a user