Does systemd expose any unit-file-parsing functionality?

Tom Lane tgl at
Thu Mar 22 01:37:39 UTC 2012

Lennart Poettering <mzerqung at> writes:
> On Wed, 21.03.12 20:39, Tom Lane (tgl at wrote:
>> ... what I find "systemctl show" producing is a line like
>> Environment=PGPORT=5432 PGDATA=/var/lib/pgsql/data PGPORT=5433
>> So I have to pick this apart, understanding that later entries override
>> earlier ones.  And the really nasty problem with it is that the layout
>> is simply broken by environment variable names or values that contain
>> spaces.  I don't mind so much needing to implement a "take the last
>> match" rule, but it'd be nice if I didn't have to tell people they can't
>> use a PGDATA path that includes spaces.  I don't have an immediate
>> proposal for making it better though.

> This is shell? If it wasn't shell the clean way would be to simply go to
> the bus and ask for this raw. Which is trivial and not prone to parsing
> problems.

Yeah, it's shell.

> But you are right, we should drop the duplicate entry. I will fix
> this. Added to the TODO list.

What would be more useful is to fix the format ambiguity.  After some
thought, one possibility is to emit a separate Environment= line for
each env var:


which is both unambiguous (at least, as long as there are not newlines
in the variable values) and natural given the input language.  If you
wanted it to not be order-sensitive then yes you'd need to get rid of
duplicates internally; don't know if that's important to you.

			regards, tom lane

More information about the devel mailing list