From 38c2a13e4b9a2de040864dbd0306cb38f329addf Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Thu, 14 Sep 2017 08:56:59 -0400 Subject: Make a few minor tweaks to the grub-helper script The check for an existing, non-directory file as $keymap_out_path was added to prevent the (unlikely) scenario of attempting writing a file to a file as if it were a directory. --- projects/grub/grub-helper | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'projects') diff --git a/projects/grub/grub-helper b/projects/grub/grub-helper index e7e8a1fe..604d4a54 100755 --- a/projects/grub/grub-helper +++ b/projects/grub/grub-helper @@ -114,6 +114,10 @@ grub_build_layout() { if ! [[ -e "${keymap_out_path}" ]]; then mkdir -p "${keymap_out_path}" + elif ! [[ -d "${keymap_out_path}" ]]; then + printf '\n%s\n' "Error: File ${keymap_out_path} is not a directory" 1>&2 + + return 1 fi "${grub_mklayout}" --output="${grub_kbd_layout}" --input="${raw_layout_path}" @@ -148,8 +152,9 @@ grub_build_floppy_image() { local grubimg="${build_path}/grub2" local tempfile="${build_path}/temp.file" - if ! ( grub_build_bootable_image "$@" ); then + if ! grub_build_bootable_image "$@"; then printf '\n%s\n\n' "Error: Failed to build a GRUB image" 1>&2 + return 1 fi @@ -161,6 +166,7 @@ grub_build_floppy_image() { dd if=/dev/zero of="${tempfile}" bs=1024 count="${size:-160}" else printf '\n%s\n\n' "Error: File ${tempfile} already exists!" 1>&2 + return 1 fi @@ -175,7 +181,8 @@ grub_build_floppy_image() { mv "${tempfile}" "${grubimg}" else printf '\n%s' "Error: Image ${grubimg##*/} is too large; " 1>&2 - printf '%s\n\n' "it must be less than ${size}KiB in size." 1>&2 + printf '%s\n\n' "it must be less than ${size}KiB in size" 1>&2 + return 1 fi } -- cgit v1.2.3-70-g09d2