[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] Comments after lines



Hi Jonas,


Thank you for reporting this issue.


On Thu, May 7, 2009 at 9:46 AM, Jonas Eriksson <jonas j eriksson ericsson com> wrote:
Hello

I have been having some trouble with comments when parsing
modprobe.d-files. To exemplify, ordinary comments work as
intended, but end-of-line-comments breaks the lens, so to speak:
===== modprobe.d/blacklist:
# this works fine
blacklist brokenmodule # this does not work
=====

I propose that either the definition of eol in util.aug is
changed thusly:
=====
diff --git a/lenses/util.aug b/lenses/util.aug
index 0dced14..ee2845c 100644
--- a/lenses/util.aug
+++ b/lenses/util.aug
@@ -51,7 +51,7 @@ Variable: del_opt_ws
 Variable: eol
  Delete end of line, including optional trailing whitespace
 *)
-  let eol = del /[ \t]*\n/ "\n"
+  let eol = del /[ \t]*(#[^\n]*\n|\n)/ "\n"

 (*
 Variable: indent
=====

..or that a ceol is defined as the redefined eol, and that this
is used instead of eol in modprobe.aug and shellvars.aug (it is
probably fitting for more .aug-files, such as hosts, grub, cron,
exports, fstab, interfaces, etc. Someone who is more certain at
this will have to acknowledge):


We have another way of dealing with this, which is to use '(eol|comment)' instead of 'eol' for the end of lines.

Quite a few lenses are already doing it this way.



Raphaël


 
=====
diff --git a/lenses/modprobe.aug b/lenses/modprobe.aug
index d61b7a0..5fb3de6 100644
--- a/lenses/modprobe.aug
+++ b/lenses/modprobe.aug
@@ -7,7 +7,7 @@ autoload xfm

 let comment = Util.comment
 let empty = Util.empty
-let eol = Util.eol
+let eol = Util.ceol

 (* modprobe.conf allows continuing a line by ending it with backslash +
   newline; the backslash + newline token is suppressed We handle an
diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
index d3e4bbe..663e581 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -3,7 +3,7 @@
 module Shellvars =
  autoload xfm

-  let eol = Util.eol
+  let eol = Util.ceol

  let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
  let eq = Util.del_str "="
diff --git a/lenses/util.aug b/lenses/util.aug
index 0dced14..20f4919 100644
--- a/lenses/util.aug
+++ b/lenses/util.aug
@@ -54,6 +54,12 @@ Variable: eol
  let eol = del /[ \t]*\n/ "\n"

 (*
+Variable: ceol
+  Delete end of line, including optional trailing whitespace and comment
+*)
+  let ceol = del /[ \t]*(#[^\n]*\n|\n)/ "\n"
+
+(*
 Variable: indent
  Delete indentation, including leading whitespace
 *)
=====

Best regards,
Jonas Eriksson

--
Jonas Eriksson
Consultant at AS/EAB/FLJ/IL
Phone: +46 8 58086281
Combitech AB
Älvsjö, Sweden

_______________________________________________
augeas-devel mailing list
augeas-devel redhat com
https://www.redhat.com/mailman/listinfo/augeas-devel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]