Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I recently assembled a lens in Augeas and now it's not functioning quite as desired.

My file contains a few references with the following syntax:

Value1 = KEY 32 OR\
   KEY 33 OR\

How do I represent the backslash newline combination and treat it as part of the same value?

EDIT - I'm running version .10.0

  let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
  let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
  let empty    = IniFile.empty

  let setting   = IniFile.entry_re
  let title   =  IniFile.indented_title_label "target" IniFile.record_label_re
  let entry    = [ key IniFile.entry_re . sep . IniFile.sto_to_comment . (comment|IniFile.eol) ] |
                 [ key IniFile.entry_re . store // . (comment|IniFile.eol) ] |
                 [ key /\![A-Za-z][A-Za-z0-9\._-]+/ . del / / " " . store /\/[A-Za-z0-9\.\/_-]+/ . (comment|IniFile.eol) ] |

  let record    = IniFile.record title entry
  let record_anon = [ label ".anon" . ( entry | empty )+ ]

  let lns       = record_anon | record*


share|improve this question
Can you post your lens code, too? –  ℝaphink Oct 15 '12 at 17:54
Are you sure your file is really an IniFile? IniFiles usually don't use a `` for multiline values, just a newline with an indented line. –  ℝaphink Oct 15 '12 at 19:55
@ℝaphink - It isn't perfect but it was easier than creating any additional primitives. –  Tim Brigham Oct 15 '12 at 20:20
I mean, do you really have sections in your file, or is it more of a Simplevars kind of file with continuated lines? –  ℝaphink Oct 15 '12 at 20:43
@ℝaphink -There are sections included. Most of my files have sections, a few use the anon entries. –  Tim Brigham Oct 15 '12 at 21:22
show 1 more comment

1 Answer

up vote 1 down vote accepted

Your lens is not written for multiline entries. If you want to support multiline entries, you need to use IniFile.entry_multiline:

let entry_multiline (kw:regexp) (sep:lens) (comment:lens)
                       = [ key kw . sep . sto_multiline? . (comment|eol) ] | comment

However, this definition doesn't recognize \ as a line continuation symbol because I've never seen an IniFile use it to this day. While \ is commonly used as a line continuation symbol for various key/value formats, IniFiles usually simply use indentation to determine if a line is a continuation of the previous one.

As a note, I don't think your definition of lns is really what you intend it to be:

let lns       = record_anon | record*

means, "one record_anon, followed by zero, one or more records", while I guess you probably mean "zero, one or more record_anon, followed by zero, one or more records", which is:

let lns       = record_anon* . record*
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.