[augeas-devel] insert comment before edited line?

Pat Riehecky riehecky at fnal.gov
Tue Dec 4 14:51:02 UTC 2012


Thanks Dominic and Raphaël

You are awesome!

On 12/04/2012 08:48 AM, Dominic Cleal wrote:
> On 04/12/12 14:28, Pat Riehecky 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.
> Comments are usually represented with a node whose label is "#comment".
>   If you do a "print" from within augtool you should see some other
> comments in this format.  Try 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/*[arg =~
> regexp('["]*/var/www/html["]*')]/#comment[following-sibling::*[1][arg =
> 'Indexes']] "removed Indexes from Options"
>
> The set expression's been expanded to find the newly created #comment
> node that is preceding the node with [arg='Indexes'].  Note also the "#
> " has been removed from the node value since the #comment will handle that.
>


-- 
Pat Riehecky




More information about the augeas-devel mailing list