Hi,

I'm using augeas to edit /etc/default/grub which is parsed using the
Shellvars lens.

I have a file that looks like this:
-----
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
-----

And the tree looks the following way:
-----
augtool> print /files/etc/default/grub/
/files/etc/default/grub
/files/etc/default/grub/#comment[1] = "If you change this file, run
'update-grub' afterwards to update"
/files/etc/default/grub/#comment[2] = "/boot/grub/grub.cfg."
/files/etc/default/grub/#comment[3] = "For full documentation of the
options in this file, see:"
/files/etc/default/grub/#comment[4] = "info -f grub -n 'Simple configuration'"
/files/etc/default/grub/GRUB_DEFAULT = "0"
/files/etc/default/grub/GRUB_TIMEOUT = "5"
/files/etc/default/grub/GRUB_DISTRIBUTOR = "`lsb_release -i -s 2>
/dev/null || echo Debian`"
/files/etc/default/grub/GRUB_CMDLINE_LINUX_DEFAULT = "\"quiet\""
/files/etc/default/grub/GRUB_CMDLINE_LINUX = "\"\""
/files/etc/default/grub/#comment[5] = "Uncomment to enable BadRAM
filtering, modify to suit your needs"
/files/etc/default/grub/#comment[6] = "This works with Linux (no patch
required) and with any kernel that obtains"
/files/etc/default/grub/#comment[7] = "the memory map information from
GRUB (GNU Mach, kernel of FreeBSD ...)"
/files/etc/default/grub/#comment[8] =
"GRUB_BADRAM=\"0x01234567,0xfefefefe,0x89abcdef,0xefefefef\""
/files/etc/default/grub/#comment[9] = "Uncomment to disable graphical
terminal (grub-pc only)"
/files/etc/default/grub/#comment[10] = "GRUB_TERMINAL=console"
/files/etc/default/grub/#comment[11] = "The resolution used on
graphical terminal"
/files/etc/default/grub/#comment[12] = "note that you can use only
modes which your graphic card supports via VBE"
/files/etc/default/grub/#comment[13] = "you can see them in real GRUB
with the command `vbeinfo'"
/files/etc/default/grub/#comment[14] = "GRUB_GFXMODE=640x480"
/files/etc/default/grub/#comment[15] = "Uncomment if you don't want
GRUB to pass \"root=UUID=xxx\" parameter to Linux"
/files/etc/default/grub/#comment[16] = "GRUB_DISABLE_LINUX_UUID=true"
/files/etc/default/grub/#comment[17] = "Uncomment to disable
generation of recovery mode menu entries"
/files/etc/default/grub/#comment[18] = "GRUB_DISABLE_RECOVERY=\"true\""
/files/etc/default/grub/#comment[19] = "Uncomment to get a beep at grub start"
/files/etc/default/grub/#comment[20] = "GRUB_INIT_TUNE=\"480 440 1\""
-----

I want to change the following part (if exists):
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
to
# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console

When I "rm /files/etc/default/grub/#comment[10]" and "save" I get an
undesired result, the comments below get scrambled - some even switch
prefixed spaces:
-----
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#The resolution used on graphical terminal

# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
# GRUB_GFXMODE=640x480
#Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux

# GRUB_DISABLE_LINUX_UUID=true
#Uncomment to disable generation of recovery mode menu entries

# GRUB_DISABLE_RECOVERY="true"
#Uncomment to get a beep at grub start

# GRUB_INIT_TUNE="480 440 1"
-----

I suspect this has something to do with how "del" is implemented and
how the tree is reconstructed back to string.

Augeas version is 1.11

Will appreciate any help.


_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to