[systemd-devel] [PATCH] ignore comments in multiline variable definitions

Michal Vyskocil mvyskocil at suse.cz
Thu Feb 14 02:31:46 PST 2013


On Wed, Feb 13, 2013 at 08:07:07PM +0100, Lennart Poettering wrote:
> On Wed, 13.02.13 20:05, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:
> 
> > Actually, the syntax already is _not_ a subset of the shell, and has its
> > own pecularities. Anyone trying to blindly follow shell rules is going
> > to be severly bitten anyway. So, why not go a bit further and change
> > the syntax in a way that is useful for our users?
> 
> It's certainly true that we are not compatible with shell, and that we
> aren't even trying to be. But in this regard I see no reason to deviate.

Hi Lennart,

variable definitions in a shell is recognized by quotes - in contrast to
systemd. For single line definition, there is no problem at all.
FOO="blah blah blah" will be parsed in a same way by both + systemd
would allow an unquoted version. And there are probably some funny
problems with quites inside definition, but this is an another story

Taking quotes into an account removes all ambiguities we are facing with
a comments and empty lines an so.

Let have

FOO="multi
#commented
definition"
#followed by a comment
BAR="and an another variable"

w/o continuation, systemd will create two single lines variables FOO and
BAR. This does not work like shell. So lets add some continuations

FOO="multi \
#commented \
definition" \
#followed by a comment \
BAR="and an another variable"

Well, this is still not correct - now we have FOO and BAR in a shell,
where systemd will

  * see two variables FOO and BAR if we skip comments (but FOO's content
    will be different)
  * one variable FOO if we will give \\\n bigger priority

There will be corner-cases in which env file will be recognized
differently from a shell. IOW this can generate some new suprised
systemd-haters.

> 
> But let's take one step back. Can you make a good case why comments
> should trump continuation lines? To me that doesn't even sound so
> useful, and it would in fact surprise me if things would work that
> way...

If I can speak for mysel, the Zbigniew's example do what I allways
wanted to have in a shell - a way how to easy replace some value, but
have the old one in-place as a backup.

Regards
Michal Vyskocil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130214/e8f8801d/attachment.pgp>


More information about the systemd-devel mailing list