diff options
author | Andrew Robbins <contact@andrewrobbins.info> | 2017-06-22 11:44:19 -0400 |
---|---|---|
committer | Andrew Robbins <contact@andrewrobbins.info> | 2017-06-23 09:25:42 -0400 |
commit | 46c6ca3b9ee3e545a41b3b0f488885b20a1c65b5 (patch) | |
tree | aa647a35566e714faa801f66a711ebb6f0da34f3 /projects/cros-scripts/install/cros-kernel-install | |
parent | 7c8e518c62c6bbe6cd2b465099c561d8d53d38e9 (diff) | |
download | librebootfr-46c6ca3b9ee3e545a41b3b0f488885b20a1c65b5.tar.gz librebootfr-46c6ca3b9ee3e545a41b3b0f488885b20a1c65b5.zip |
Fixed printf calls & replaced 'echo' w/ printf.
All printf calls should now be properly formatted; prior, the
format specifier string was erroneously used for both the format
specifiers and the string to be printed. 'env' is now used to
locate the printf binary so as to avoid potentially using a shell
builtin. Lastly, all calls to 'echo' within the new build system
have been replaced with printf for consistency/portability purposes.
Diffstat (limited to 'projects/cros-scripts/install/cros-kernel-install')
-rwxr-xr-x | projects/cros-scripts/install/cros-kernel-install | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/projects/cros-scripts/install/cros-kernel-install b/projects/cros-scripts/install/cros-kernel-install index 589a36c0..e45915e9 100755 --- a/projects/cros-scripts/install/cros-kernel-install +++ b/projects/cros-scripts/install/cros-kernel-install @@ -23,22 +23,22 @@ MODEL="model" NAME="name" usage() { - printf "$executable [action] [storage] [kernel image|kernel modules]\n" >&2 + env printf '%s\n' "$executable [action] [storage] [kernel image|kernel modules]" >&2 - printf "\nActions:\n" >&2 - printf " backup - Backup kernel image\n" >&2 - printf " image - Install kernel image\n" >&2 - printf " modules - Install kernel modules" >&2 + env printf '\n%s\n' 'Actions:' >&2 + env printf '%s\n' ' backup - Backup kernel image' >&2 + env printf '%s\n' ' image - Install kernel image' >&2 + env printf '%s\n' ' modules - Install kernel modules' >&2 usage_storage - printf "\nEnvironment variables:\n" >&2 - printf " VBOOT_KEYS_PATH - Path to the vboot keys\n" >&2 - printf " VBOOT_TOOLS_PATH - Path to vboot tools\n" >&2 + env printf '\n%s\n' 'Environment variables:' >&2 + env printf '%s\n' ' VBOOT_KEYS_PATH - Path to the vboot keys' >&2 + env printf '%s\n' ' VBOOT_TOOLS_PATH - Path to vboot tools' >&2 } usage_storage() { - printf "\nStorage:\n" >&2 + env printf '\n%s\n' 'Storage:' >&2 local nodes=$( ls "$SYS_BLOCK_PATH" ) local node_path @@ -58,7 +58,7 @@ usage_storage() { continue fi - printf " $node_path - $name\n" >&2 + env printf '%s\n' " $node_path - $name" >&2 done } @@ -68,9 +68,9 @@ storage_affect_confirm() { local name=$( storage_name "$storage_path" ) local confirm - printf "This is going to affect the following storage:\n" - printf " $storage_path - $name\n" - printf "Press enter to confirm: " + env printf '%s\n' 'This is going to affect the following storage:' + env printf '%s\n' " $storage_path - $name" + env printf '%s' 'Press enter to confirm: ' read confirm } @@ -95,17 +95,17 @@ storage_name() { return 0 fi - name=$( echo "$name" | sed -e "s/^[[:space:]]*//;s/[[:space:]]*$//" ) + name=$( env printf '%s\n' "$name" | sed -e "s/^[[:space:]]*//;s/[[:space:]]*$//" ) if [ -f "$vendor_path" ] then vendor=$( cat "$vendor_path" ) - vendor=$( echo "$vendor" | sed -e "s/^[[:space:]]*//;s/[[:space:]]*$//" ) + vendor=$( env printf '%s\n' "$vendor" | sed -e "s/^[[:space:]]*//;s/[[:space:]]*$//" ) name="$vendor $name" fi - echo "$name" + env printf '%s\n' "$name" } storage_partition_path() { @@ -124,7 +124,7 @@ storage_partition_path() { return 1 fi - echo "$storage_partition_path" + env printf '%s\n' "$storage_partition_path" } storage_partition_mount_path() { @@ -132,7 +132,7 @@ storage_partition_mount_path() { local storage_partition_mount_path=$( udisksctl info -b "$storage_partition_path" | grep "MountPoints" | sed "s/.*MountPoints:[[:space:]]*\(.*\)/\1/g" ) - echo "$storage_partition_mount_path" + env printf '%s\n' "$storage_partition_mount_path" } storage_kernel_path() { @@ -155,13 +155,13 @@ backup() { if [ -z "$storage_kernel_path" ] then - printf "No kernel partition found on storage $storage_path\n" >&2 + env printf '%s\n' "No kernel partition found on storage $storage_path" >&2 return 1 fi cat "$storage_kernel_path" > "$kernel_image_path" - printf "\nBacked up kernel image to $kernel_image_path\n" + env printf '\n%s\n' "Backed up kernel image to $kernel_image_path" } image() { @@ -172,7 +172,7 @@ image() { if [ -z "$storage_kernel_path" ] then - printf "No kernel partition found on storage $storage_path\n" >&2 + env printf '%s\n' "No kernel partition found on storage $storage_path" >&2 return 1 fi @@ -181,7 +181,7 @@ image() { cat "$kernel_image_path" > "$storage_kernel_path" sync - printf "\nInstalled kernel image on storage $storage_path\n" + env printf '\n%s\n' "Installed kernel image on storage $storage_path" } modules() { @@ -192,7 +192,7 @@ modules() { if [ -z "$storage_rootfs_path" ] then - printf "No rootfs partition found on storage $storage_path\n" >&2 + env printf '%s\n' "No rootfs partition found on storage $storage_path" >&2 return 1 fi @@ -208,7 +208,7 @@ modules() { udisksctl unmount -b "$storage_rootfs_path" - printf "\nInstalled kernel modules on storage $storage_path\n" + env printf '\n%s\n' "Installed kernel modules on storage $storage_path" } requirements() { @@ -221,7 +221,7 @@ requirements() { if [ -z "$requirement_path" ] then - printf "Missing requirement: $requirement\n" >&2 + env printf '%s\n' "Missing requirement: $requirement" >&2 exit 1 fi done |