setup-efi-ivi: use printf instead of echo
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 26 Jun 2013 09:21:37 +0000 (12:21 +0300)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 26 Jun 2013 09:21:37 +0000 (12:21 +0300)
This is better because echo is very different in different shells, and
interpret various special bytes differently, and its behavior may sometimes be
very surprizing.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
packaging/setup-efi-ivi.spec
setup-efi-ivi

index 77c6b31..023ef45 100644 (file)
@@ -10,6 +10,7 @@ Requires:       gummiboot
 Requires:       /usr/bin/sed
 Requires:       /usr/bin/sort
 Requires:       /usr/bin/grep
+Requires:       /usr/bin/printf
 ExclusiveArch:  %{ix86} x86_64
 
 %description
index 7f00b92..22ae9a0 100755 (executable)
@@ -9,7 +9,7 @@ PROG="setup-efi-ivi"
 # This is a helper function which prints an error message and exits
 fatal()
 {
-       echo "$PROG: error: $1" 1>&2
+       printf "%s\n" "$PROG: error: $1" 1>&2
        exit 1
 }
 
@@ -26,15 +26,15 @@ boot_fstype=
 
 while [ "$pnum" -lt "$INSTALLERFW_PART_COUNT" ]; do
        mountpoint="INSTALLERFW_PART${pnum}_MOUNTPOINT"
-       mountpoint="$(eval echo '$'$mountpoint)"
+       mountpoint="$(eval printf "%s" '$'$mountpoint)"
 
        # Find out all the required data for the root and boot partition
        if [ "$mountpoint" == "/" ]; then
                root_partuuid=INSTALLERFW_PART${pnum}_PARTUUID
-               root_partuuid="$(eval echo '$'$root_partuuid)"
+               root_partuuid="$(eval printf "%s" '$'$root_partuuid)"
        elif [ "$mountpoint" == "$boot_mountpoint" ]; then
                boot_fstype=INSTALLERFW_PART${pnum}_FSTYPE
-               boot_fstype="$(eval echo '$'$boot_fstype)"
+               boot_fstype="$(eval printf "%s" '$'$boot_fstype)"
        fi
 
        pnum="$((pnum+1))"
@@ -59,7 +59,7 @@ mkdir -p "$boot_mountpoint/EFI/boot"
 
 # Find out the latest kernel binary in boot partition
 vmlinuz="$(ls -1 "$boot_mountpoint" | grep "^vmlinuz-" | sort -r | head -n1)"
-vmlinuz_version="$(echo $vmlinuz | sed -e 's/vmlinuz-\(.*\)/\1/')"
+vmlinuz_version="$(printf "%s" $vmlinuz | sed -e 's/vmlinuz-\(.*\)/\1/')"
 
 # Create the gummiboot configuration file
 mkdir -p "$boot_mountpoint/loader"