>>> <[email protected]> schrieb am 27.08.2020 um 18:11 in Nachricht
<[email protected]>:
> Consider
>
> [Unit]
> Description=Is it looking for ${} construct in the wrong place?
> [Service]
> Type=oneshot
> ExecStart=/bin/bash ‑c 'set ‑x; declare ‑r str="1 2"; echo ${str}; echo
$str;
It seems systemd substitutes ${str} before the command is executed. See
systemd.service(5):
Basic environment variable substitution is supported. Use "${FOO}" as
part of a word, or as a word of its own, on the command line, in which
case it will be replaced by the value of the environment variable
including all whitespace it contains, resulting in a single argument.
Did you try to "escape" the "{" and "}"?
> exit 0;'
>
> When ran, the journal has:
>
> bash[14190]: + declare ‑r 'str=1 2'
> bash[14190]: + echo
> bash[14190]: + echo 1 2
> bash[14190]: 1 2
> bash[14190]: + exit 0
>
> Note the top bash[14190]: + echo line. It has no arguments. Since the other
> echo line
> has its 1 2 arguments, I find this behaviour inconsistent. And surprising.
> As such, I
> think this is a bug.
> It could be that the ${NAME} construct is looked for in the environment. But
> then, why
> $NAME works in the script, but not ${NAME}?
>
> In addition, for the top bash[14190]: + echo line, isn't there a missing
> empty, just
> [bash[14190]:, line?
>
> Same results were obtained with systemd 241‑7 and 246.2.
>
> u34.
> _______________________________________________
> systemd‑devel mailing list
> systemd‑[email protected]
> https://lists.freedesktop.org/mailman/listinfo/systemd‑devel
_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel