[augeas-devel] [shellvars] value with spaces
David Lutterkort
lutter at redhat.com
Fri Oct 17 17:03:16 UTC 2008
On Fri, 2008-10-17 at 12:55 +0200, Free Ekanayaka wrote:
> Hi,
>
> the /etc/default/apmd file contains a variable with a space inside its
> value:
>
> APMD="--proxy-timeout 30"
>
> and priting the variable with augtool results in:
>
> ~$ augtool print /files/etc/default/apmd/APMD
> /files/etc/default/apmd/APMD = "\"--proxy-timeout 30\""
The way this is printed is probably a bad idea, since it's not how you
type it in. Can you file a bug about that inconsistency ?
When augtool splits its command line into tokens, it generally breaks
them at spaces; to have values with spaces you cna enclose them either
in single or douple quotes, but augtool does not understand the escaping
of quote characters (cause I was too lazy to implement it).
In a nutshell, here's various ways to set things interactively with
augtool:
augtool> set /path " " # value of path is a single space
augtool> set /path "'" # value of path is a single quote
character
augtool> set /path '"' # value of path is a doublequote
character
augtool> set /path '" "' # value of path is a dq char, a space, another dq char
> Now, if I try to set a new value, for example "--proxy-timeout 31",
> this won't work, even if I escape the quotes:
>
> ~$ (echo set /files/etc/default/apmd/APMD "--proxy-timeout 31"; echo save)|augtool
> augtool> Too many arguments for set
> augtool> augtool>
You need to take into account that the shell has its own ideas about
quoting; the line that augtool gets is the same as typing
augtool> set /files/etc/default/apmd/APMD --proxy-timeout 31
That's why it's complaining about too many arguments for set.
> ~$ (echo set /files/etc/default/apmd/APMD "\"--proxy-timeout 31\""; echo save)|augtool
> augtool> augtool> Saving failed
> augtool>
Close, but not quite right: now you're doing the same as
augtool> set /files/etc/default/apmd/APMD "--proxy-timeout 31"
augtool> save
that would result in having the line
APMD=--proxy-timeout 31
in /etc/default and Augeas knows that that is wrong, so it refuses to
save. (The shell would try to run the command '31' with APMD set to
--proxy-timeout when /etc/default is sourced)
What you want (in augtool) is
augtool> set /files/etc/default/apmd/APMD '"--proxy-timeout 31"'
augtool> save
>From the shell, that has to be
~$ (echo set /files/etc/default/apmd/APMD "'\"--proxy-timeout 31\"'"; echo save)|augtool
Ain't quoting fun ?
David
More information about the augeas-devel
mailing list