[augeas-devel] [Augeas] #230: Parse error on /etc/default/console-setup

Augeas trac at fedorahosted.org
Sat Nov 19 22:52:42 UTC 2011


#230: Parse error on /etc/default/console-setup
-----------------------+----------------------------------------------------
  Reporter:  domcleal  |       Owner:  raphink  
      Type:  defect    |      Status:  assigned 
  Priority:  minor     |   Milestone:  next     
 Component:  Augeas    |     Version:  0.8.0    
Resolution:            |    Keywords:  shellvars
-----------------------+----------------------------------------------------
Comment (by raphink):

 Correction, adding `Util.indent` inside conditionals:

 {{{
 diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
 index 1dcd095..e12101c 100644
 --- a/lenses/shellvars.aug
 +++ b/lenses/shellvars.aug
 @@ -6,8 +6,7 @@ module Shellvars =
    let eol = Util.eol

    let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
 -  let eq = Util.del_str "="
 -  let comment = Util.comment
 +  let eq = Util.del_str "=" let comment = Util.comment
    let comment_or_eol = Util.comment_or_eol
    let empty   = Util.empty
    let xchgs   = Build.xchgs
 @@ -59,7 +58,16 @@ module Shellvars =
        . [ label "args" . store /[^; \t\n][^;\n]+[^; \t\n]|[^ \t;\n]+/ ]
        . semicol . eol ]

 -  let lns = (comment | empty | source | kv | unset | bare_export |
 builtin) *
 +  let rec cond_if =
 +    [
 +      del /if[ \t]+/ "if " . label "@if"
 +      . store /[^; \t\n][^;\n]+[^; \t\n]|[^ \t;\n]+/
 +      . del /(;|([ \t]*\n))[ \t\n]*then[ \t]*(;|\n)/ "; then\n"
 +      . (Util.indent . (comment | empty | source | kv | unset |
 bare_export | builtin | cond_if)) +
 +      . Util.del_str "fi" . eol ]
 +
 +
 +  let lns = (comment | empty | source | kv | unset | bare_export |
 builtin | cond_if) *

    let sc_incl (n:string) = (incl ("/etc/sysconfig/" . n))
    let filter_sysconfig =
 diff --git a/lenses/tests/test_shellvars.aug
 b/lenses/tests/test_shellvars.aug
 index 47e03d2..3d47f96 100644
 --- a/lenses/tests/test_shellvars.aug
 +++ b/lenses/tests/test_shellvars.aug
 @@ -142,6 +142,16 @@ unset ONBOOT    #   We do not want this var
    { "VAR1" = "\"this;is;a;test\"" }
    { "VAR2" = "this" }

 +  (* Bug 230: parse conditions *)
 +  test Shellvars.lns get "if [ -f /etc/default/keyboard ]; then\n.
 /etc/default/keyboard\nfi\n" =
 +  { "@if" = "[ -f /etc/default/keyboard ]" { ".source" =
 "/etc/default/keyboard" } }
 +
 +  (* Recursive condition *)
 +  test Shellvars.lns get "if [ -f /tmp/file1 ]; then\nif [ -f /tmp/file2
 ]; then\n. /tmp/file2\nfi\nfi\n" =
 +  { "@if" = "[ -f /tmp/file1 ]"
 +    { "@if" = "[ -f /tmp/file2 ]"
 +      { ".source" = "/tmp/file2" } } }
 +

  (* Local Variables: *)
  (* mode: caml       *)
 }}}

 The result for the problematic file is:

 {{{
 /files/etc/default/console-setup/@if = "[ -f /etc/default/keyboard ]"
 /files/etc/default/console-setup/@if/.source = "/etc/default/keyboard"
 }}}

-- 
Ticket URL: <https://fedorahosted.org/augeas/ticket/230#comment:6>
Augeas <http://augeas.net/>
a configuration API




More information about the augeas-devel mailing list