[Libguestfs] newlines with write-append

Olaf Hering olaf at aepfle.de
Mon Jan 20 19:54:17 UTC 2014


Silly bash scripts have stuff like below to get things done, but equally
silly guestfish scripts fail to add the required newline. Why is that?

echo "$dev1 $mnt1 $fs $opts 1 2" >> /etc/fstab
echo "$dev2 $mnt2 $fs $opts 1 2" >> /etc/fstab

write-append /etc/fstab "$dev1 $mnt1 $fs $opts 1 2" : \
write-append /etc/fstab "$dev2 $mnt2 $fs $opts 1 2" : \


Even adding variants of \n does not help. 

Simple testcase:

write /etc/fstab "#\n" : \
write-append /etc/fstab '#1\n' : \
write-append /etc/fstab '#2\\n' : \
cat /etc/fstab : \
quit

...
libguestfs: trace: cat = "#\n#1\n#2\\n"
#\n#1\n#2\\n
libguestfs: trace: shutdown
...

I guess using "sh" will be my workaround.

Olaf




More information about the Libguestfs mailing list