[augeas-devel] shellvars.aug: How to set /files/etc/file/field to "a 'b'" ?
Dominic Cleal
dcleal at redhat.com
Thu Feb 16 12:36:11 UTC 2012
Hi Peter,
On 16/02/12 12:10, Peter Valdemar Mørch wrote:
> Here, I'll use /files/etc/default/snmpd/SNMPDOPTS as an example. The
> same applies to any shellvars.aug file, I guess:
>
> The default value of SNMPDOPTS in the file:
> SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
>
> How do I set that to be:
> SNMPDOPTS="a 'b'"
> (that is: doublequote a space singlequote b singlequote doublequote)
> ?
>
> First I set it manually with vi. Then:
> augtool> print /files/etc/default/snmpd/SNMPDOPTS
> /files/etc/default/snmpd/SNMPDOPTS = "\"a 'b'\""
>
> But I've tried a number of things:
>
> augtool> set files/etc/default/snmpd/SNMPDOPTS "\"a 'b'\""
> Too many arguments. Command set takes only 2 arguments
In Augeas 0.10.0, this will now work:
$ augtool -r .
augtool> set /files/etc/default/snmpd/SNMPDOPTS "\"a 'b'\""
augtool> print /files/etc/default/snmpd/
/files/etc/default/snmpd
/files/etc/default/snmpd/SNMPDOPTS = "\"a 'b'\""
augtool> save
Saved 1 file(s)
augtool>
$ cat etc/default/snmpd
SNMPDOPTS="a 'b'"
Probably not in previous versions though, see below.
> Is it possible to mix'n'match ' and " in config files?
It is possible now, but older versions of augtool had poor or
non-existent support for it. It improved in 0.10.0, plus a couple of
days ago I improved the support again for our next release.
The API should fully support nested quotes, it's just the
aug_srun/augtool parsing that didn't.
> What are the rules of quoting, and what does augtool consider a single
> argument
The support in the unreleased version is "documented" in these unit tests:
http://git.fedorahosted.org/git/?p=augeas.git;a=blob;f=tests/run.tests#l300
The support in 0.10.0 is shown here:
http://git.fedorahosted.org/git/?p=augeas.git;a=blob;f=tests/run.tests;hb=3fb654#l242
Hope that helps.
--
Dominic Cleal
Red Hat Consulting
m: +44 (0)7817 878113
More information about the augeas-devel
mailing list