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

Augeas trac at fedorahosted.org
Mon Nov 21 22:56:10 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):

 Here is a proposed implementation for a recursive conditional system (diff
 is based off 867cc369b35a0ce948e1c9a92828da5611031a8d):

 {{{
 diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
 index 1dcd095..4ff6e47 100644
 --- a/lenses/shellvars.aug
 +++ b/lenses/shellvars.aug
 @@ -59,7 +59,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       *)
 }}}

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




More information about the augeas-devel mailing list