[augeas-devel] shellvars.aug: How to set /files/etc/file/field to "a 'b'" ?

Peter Valdemar Mørch peter at morch.com
Thu Feb 16 12:10:12 UTC 2012


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
augtool> set files/etc/default/snmpd/SNMPDOPTS \"a 'b'\"
Too many arguments. Command set takes only 2 arguments
augtool> set files/etc/default/snmpd/SNMPDOPTS '"a \'b\'"'
Too many arguments. Command set takes only 2 arguments
augtool> set files/etc/default/snmpd/SNMPDOPTS "'a \'b'\'"
augtool> save
Saving failed
augtool> print /augeas/files/etc/default/snmpd/error/message
/augeas/files/etc/default/snmpd/error/message = "Malformed child node
'SNMPDOPTS'"

Is it possible to mix'n'match ' and " in config files?

What are the rules of quoting, and what does augtool consider a single
argument, because this works:
augtool> set files/etc/default/snmpd/SNMPDOPTS "'a b'"
augtool> save
Saved 1 file(s)

But this doesn't:
augtool> set files/etc/default/snmpd/SNMPDOPTS "a b"
augtool> save
Saving failed
augtool> print /augeas/files/etc/default/snmpd/error/message
/augeas/files/etc/default/snmpd/error/message = "Malformed child node
'SNMPDOPTS'"
augtool> set files/etc/default/snmpd/SNMPDOPTS 'a b'
augtool> print /augeas/files/etc/default/snmpd/error/message
/augeas/files/etc/default/snmpd/error/message = "Malformed child node
'SNMPDOPTS'"

I need this for another shellvars script in /etc, where I'd like to
mix ' and " like the shell allows.

Peter
-- 
Peter Valdemar Mørch
http://www.morch.com




More information about the augeas-devel mailing list