[systemd-devel] Accpetance of Environment Variables in Attributes

Ede Wolf listac at nebelschwaden.de
Sat Jun 27 12:01:33 UTC 2020


Thanks again for your in depth reply.

 > it's a very different kind of language, as these specifiers are
 > defined by systemd itself

Maybe someday someone will find a safe way to inject addtionally, 
arbitrary values into systemd. There are still some free letters left 
that can be prefixed with a % :)

Until then I'll stick with dedicated unit files.

Ede


Am 26.06.20 um 15:27 schrieb Lennart Poettering:
> On Do, 25.06.20 20:25, Ede Wolf (listac at nebelschwaden.de) wrote:
> 
>> Does work, so %i works, $SOMETHING not. Different naming, different way of
>> invocation, I am aware of that, but in general it still the usage of
>> variables. And the likes of %H, %m or %v are some form of environment,
>> aren't they?
> 
> Sure, you could claim this was a very specific form of templating. But
> it's a very different kind of language, as these specifiers are
> defined by systemd itself and are not affected by the contents of the
> unit file itself. I.e. you cannot go and say within a unit file that
> %m shall now resolve to "foo", and that %v shall now be
> "xyz". Instead, these expansions are defined by the unit file language
> itself, not by the unit file stanzas you place them in. That
> difference is quite major: the value of each specifier expansion is
> already well-defined and fixed at the moment we begin parsing the unit
> file (and its drop-ins) and their meaning does not change based on
> anything you could put in the file.
> 
> Scripting languages that know env vars or generic templating languages
> are quite different there: you come up with variables, you assign them
> at the top and then you can resolve them further down. This implies a
> top-down, iterative order of execution. And we don't want that. Use m4
> for that or shell. It's what they do, what they are good in.
> 
> It's the distinction between declarative languages and iterative
> languages. We provide shortcuts to some concepts, but that's really
> it, otherwise we are declarative and never iterative.
> 
>>> If you want a shell, use a shell.
>>
>> Given the dominance of systemd, this is only in parts realistic. This is not
>> meant to critisize systemd itself, just this rather bold statement. As shown
>> above, variables (specifiers, whatever you call them) are not shell
>> specific.
> 
> They are not shell specific. You could also use m4 if you want a
> templating language, there's no shame in that. But systemd is
> certainly not in the business of inventing yet another shell or
> generic templating language.
> 
> Lennart
> 
> --
> Lennart Poettering, Berlin
> 



More information about the systemd-devel mailing list