Page 1 of 1
What's happening with this? [Solved]
Posted: 30 Sep 2017, 00:00
by Ed_P
A small subroutine in a script.
Code: Select all
txtbld=$(tput bold) # Bold
rst=$(tput sgr0) # Reset
function Bold() {
echo -e $txtbld"$1"$rst "$2";
}
Works great with everything but this.
Code: Select all
Bold "Cmdline: " "`cat /proc/cmdline`"
It produces:
Code: Select all
Cmdline: quietoot\syslinux
mlinuz extramod=/Modules;/Modsavedat volume=33 reboot=cold initrd=boot\syslinux\initrd.xz
Rather than:
Code: Select all
guest@porteus:~$ echo "Cmdline: " "`cat /proc/cmdline`"
Cmdline: quiet \boot\syslinux\vmlinuz extramod=/Modules;/Modsavedat volume=33 reboot=cold initrd=boot\syslinux\initrd.xz
guest@porteus:~$
The \b and \v are doing something wrong.
What's happening with this?
Posted: 30 Sep 2017, 12:20
by Bogomips
If memory serves me right:
\b corres to Backspace
\v corres to Vertical Space
What's happening with this?
Posted: 30 Sep 2017, 13:54
by Bogomips
Two workarounds:
Code: Select all
guest@porteus:~$ w="quiet \boot\syslinux\vmlinuz extramod=/Modules;/Modsavedat"
guest@porteus:~$ echo -e $w
quietoot\syslinux
mlinuz extramod=/Modules;/Modsavedat
guest@porteus:~$ echo $w
quiet \boot\syslinux\vmlinuz extramod=/Modules;/Modsavedat
Code: Select all
guest@porteus:~$ w="quiet \boot\syslinux\vmlinuz extramod=/Modules;/Modsavedat"
guest@porteus:~$ y=${w//\\/\\\\}
guest@porteus:~$ echo "$y"
quiet \\boot\\syslinux\\vmlinuz extramod=/Modules;/Modsavedat
guest@porteus:~$ echo $y
quiet \\boot\\syslinux\\vmlinuz extramod=/Modules;/Modsavedat
guest@porteus:~$ echo -e $y
quiet \boot\syslinux\vmlinuz extramod=/Modules;/Modsavedat
guest@porteus:~$ w="quiet \boot\syslinux\vmlinuz extramod=/Modules;/Modsavedat \ "
guest@porteus:~$ y=${w//\\/\\\\}
guest@porteus:~$ echo $y
quiet \\boot\\syslinux\\vmlinuz extramod=/Modules;/Modsavedat \\
guest@porteus:~$ echo -e $y
quiet \boot\syslinux\vmlinuz extramod=/Modules;/Modsavedat \
What's happening with this?
Posted: 30 Sep 2017, 14:21
by burdi01
Where do the backslashes in your /proc/cmdline come from? For as far as I am aware syslinux "understands" forward slashes in filepaths/names even on fat/ntfs partitions.
What's happening with this?
Posted: 30 Sep 2017, 18:15
by Ed_P
Bogomips wrote: ↑30 Sep 2017, 13:54
Two workarounds:
Wow!! Thank you for pointing out the problem
Bogomips.
After reading up on the purpose of the -e option I found a 3rd workaround.
Code: Select all
guest@porteus:~$ echo -e "Cmdline: " "`cat /proc/cmdline`"
Cmdline: quietoot\syslinux
mlinuz extramod=/Modules;/Modsavedat volume=33 reboot=cold changes=EXIT:/porteus/porteussave.dat noload=porteussave.dat.xzm initrd=boot\syslinux\initrd.xz
guest@porteus:~$ echo -E "Cmdline: " "`cat /proc/cmdline`"
Cmdline: quiet \boot\syslinux\vmlinuz extramod=/Modules;/Modsavedat volume=33 reboot=cold changes=EXIT:/porteus/porteussave.dat noload=porteussave.dat.xzm initrd=boot\syslinux\initrd.xz
burdi01 wrote: ↑30 Sep 2017, 14:21
Where do the backslashes in your /proc/cmdline come from? For as far as I am aware syslinux "understands" forward slashes in filepaths/names even on fat/ntfs partitions.
And excellent question
burdi01. In this situation they come from my refind.conf file.
Code: Select all
menuentry "Porteus menu (F2)" {
volume KERNELS
icon EFI/BOOT/icons/os_porteus.png
loader boot/syslinux/vmlinuz
initrd boot/syslinux/initrd.xz
options "extramod=/Modules;/Modsavedat volume=33 reboot=cold"
submenuentry "Save changes" {
add_options "changes=EXIT:/porteus/porteussave.dat noload=porteussave.dat.xzm"
}
submenuentry "Always fresh" {
add_options "nomagic base_only norootcopy"
}
submenuentry "Boot to copy2ram mode" {
add_options "copy2ram"
}
submenuentry "Text mode" {
add_options "3"
}
submenuentry "pxe-boot" {
add_options "pxe"
}
}
So where do the backslashes come from.
Code: Select all
txtbld=$(tput bold) # Bold
rst=$(tput sgr0) # Reset
function Bold() {
echo -E $txtbld"$1"$rst "$2";
}