With systemd units that have arguments, hypens and other specifiers are replaced with forward slashes.
Some unit names reflect paths existing in the file system namespace. Example: a device unit dev-sda.device refers to a device with the device node /dev/sda in the file system namespace. If this applies, a special way to escape the path name is used, so that the result is usable as part of a filename. Basically, given a path, "/" is replaced by "-", and all other characters which are not ASCII alphanumerics are replaced by C-style "\x2d" escapes
I was trying to pass in an argument with a hyphen in it and I noticed that the systemd unit doesn't replace my hyphens with a slash. So are hyphens not always relaced? Or am I just interpreting things incorrectly?
Basically I want to pass in a string to a systemd unit that passes a string to the executable I'm running in the unit.
Say I have a unit
exampleunit@.service, inside the unit I want to execute :
If I try to pass in the argument with a hyphen to the following unit like this:
$ systemctl start firstname.lastname@example.org ExecStart=/usr/local/bin/my_script %i
Wont it convert the string to
In my testing the hyphen is not replaced.
I made a unit:
[Unit] Description=Test arg %i [Service] ExecStart=/usr/bin/echo "arg: %i"
systemctl start testunit@test-hyphen
The result doesn't replace the hyphen:
$ journalctl -u testunit@test-hyphen Journal file /email@example.com is truncated, ignoring file. -- Logs begin at Fri 2016-06-10 18:15:25 PDT, end at Sat 2016-09-24 23:12:42 PDT Sep 24 23:12:25 Archon systemd: Started Test arg test-hyphen. Sep 24 23:12:25 Archon echo: arg: test-hyphen