augeas icon indicating copy to clipboard operation
augeas copied to clipboard

Shellvars: cannot parse two VAR=value in the same line

Open ptoscano opened this issue 6 years ago • 2 comments

The Shellvars lens cannot parse a line that has two VAR=value entries in the same line.

For example:

$ cat foo
FOO=bar MOO=value
$ augtool -t 'Shellvars incl /foo' -r .
augtool> print /files
/files
augtool> print /augeas//error
/augeas/files/foo/error = "parse_failed"
/augeas/files/foo/error/pos = "11"
/augeas/files/foo/error/line = "1"
/augeas/files/foo/error/char = "11"
/augeas/files/foo/error/lens = "/usr/share/augeas/lenses/dist/shellvars.aug:248.12-.60:"
/augeas/files/foo/error/message = "Syntax error"

This can be reproduced in Augeas 1.10.1.

This was originally reported as RH #1534424

ptoscano avatar Jul 02 '18 11:07 ptoscano

I can reproduce that, too.

I am somewhat hesitant to touch this, since the Shellvars lens has grown to be quite complex (it parses a lot of actual shell scripts, not just simple 'var=value' files) Fixing this issue would require quite a bit of work on the lens, as we'd have to make sure that your example gets parsed as two variable assignments, even though A="a B=b" is only one assignment.

Before I delve into this, how important is fixing this, and how often do users run into this issue ?

lutter avatar Jul 18 '18 16:07 lutter

Before I delve into this, how important is fixing this, and how often do users run into this issue ?

The original issue was a RH ifcfg configuration file (i.e. /etc/sysconfig/network-scripts/ifcfg-*) with two variables in a single line. This works only because it was used with "old" ifup/ifdown, which source those files as shell scripts. Newer users of those files, like NetworkManager, do not handle that syntax, and assume a simpler VAR=value syntax in each line.

So if this can be fixed in one way or another without too much effort, or breaking other stuff, that's good -- otherwise, I'd not put priority on this, as it is (IMHO) a very specific corner case.

Of course, since the lens involved is Shellvars as you mention too, this might affect other files as well. OTOH, considering there were no other reports of such issues, it seems like it is not a big issue after all.

ptoscano avatar Jul 19 '18 13:07 ptoscano