[augeas-devel] insert comment before edited line?

Raphaël Pinson raphink at gmail.com
Tue Dec 4 14:46:30 UTC 2012


Hi Pat,


On Tue, Dec 4, 2012 at 3:28 PM, Pat Riehecky <riehecky at fnal.gov> wrote:

> Hello,
>
> I'm trying to put a comment in right above a line before I change it.  I'm
> going to be performing some edits on systems I do not administer.  Leaving
> behind reasons why some things were changed should help explain things for
> the real administrators in the future.
>
> In particular I've tried:
>
> ins 99999 before /files/etc/httpd/conf/httpd.**conf/*[arg =~
> regexp('["]*/var/www/html["]*'**)]/*[arg = 'Indexes']
> set /files/etc/httpd/conf/httpd.**conf/99999 "# removed Indexes from
> Options"
>
> but that does not seem to be right.
>
>

Indeed. Comments are mapped as #comment nodes, not seq nodes. Your node
needs to be named "#comment", with a value of "removed Indexes from
Options" (without a leading spaces, they are removed by Augeas), so
something like:

    ins #comment before /files/etc/httpd/conf/httpd.conf/*[arg =~
regexp('["]*/var/www/html["]*')]/*[arg = 'Indexes']
    set /files/etc/httpd/conf/httpd.conf/#comment[.=""] "removed Indexes
from Options"

Note that this is not idempotent though: if you run it several times, you
will get several comment nodes. The easiest way to make it idempotent would
be to add an rm before the ins, to ensure only one comment with value
"removed Indexes from Options" is present.


Raphaël
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20121204/12ae4c1c/attachment.htm>


More information about the augeas-devel mailing list