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

Re: [augeas-devel] Problems creating _almost empty_ file



Hi Štěpán,

On Thu, Aug 2, 2018 at 8:45 AM, Štěpán Balážik <stepan balazik nic cz> wrote:
 
Now, when I want to create similar programmatically using augtool I run into this:

$ augtool
augtool> set tmp/test2.min/file
augtool> save
error: Failed to execute command
saving failed (run 'errors' for details)
augtool> errors
Error in /tmp/test2.min:1.0 (parse_skel_failed)
  Input string does not match at all
  Lens: /usr/share/augeas/lenses/minimal.aug:8.10-.142:

When I was trying to create empty (or almost empty) file like this one using the lenses distributed with Augeas (the one for /etc/hosts for example) I ran to no such problems so I suppose I am doing something wrong.


The problem you are running into is that Augeas parses the original file right before it saves changes; that is necessary to recover things that are in the file but not in the tree, like whitespace. Your lens does not accept an empty file, it  requires that a file contains, at a minimum, "BEGIN\nEND\n". If you change your lens to accept an empty file (e.g., by putting a '?' at the end of your definition of lns), all should be well.

David


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