What's happening with this? [Solved]

Technical issues/questions of an intermediate or advanced nature.
Post Reply
User avatar
Ed_P
Contributor
Contributor
Posts: 3403
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

What's happening with this? [Solved]

Post#1 by Ed_P » 30 Sep 2017, 00:00

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. :(
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

What's happening with this?

Post#2 by Bogomips » 30 Sep 2017, 12:20

If memory serves me right:
\b corres to Backspace
\v corres to Vertical Space
:)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

What's happening with this?

Post#3 by Bogomips » 30 Sep 2017, 13:54

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 \
    
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

burdi01
Black ninja
Black ninja
Posts: 67
Joined: 18 Aug 2013, 12:09
Distribution: Slackware, Xubuntu
Location: The Netherlands

What's happening with this?

Post#4 by burdi01 » 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.
:D

User avatar
Ed_P
Contributor
Contributor
Posts: 3403
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

What's happening with this?

Post#5 by Ed_P » 30 Sep 2017, 18:15

Bogomips wrote:
30 Sep 2017, 13:54
Two workarounds:
Wow!! Thank you for pointing out the problem Bogomips. :friends: 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 
:happy62:
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.
:D
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"; 
}
:good:
Ed

Post Reply