diff options
author | Andrew Robbins <contact@andrewrobbins.info> | 2017-09-14 08:56:59 -0400 |
---|---|---|
committer | Andrew Robbins <contact@andrewrobbins.info> | 2017-09-14 08:56:59 -0400 |
commit | 38c2a13e4b9a2de040864dbd0306cb38f329addf (patch) | |
tree | ac02f5971be5d0a60650545ce25b3dd7ff84ab6d /projects/grub/grub-helper | |
parent | 3359f8ef92d120f03e80b108f0fa68ae1882e90f (diff) | |
download | librebootfr-38c2a13e4b9a2de040864dbd0306cb38f329addf.tar.gz librebootfr-38c2a13e4b9a2de040864dbd0306cb38f329addf.zip |
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.
Diffstat (limited to 'projects/grub/grub-helper')
-rwxr-xr-x | projects/grub/grub-helper | 11 |
1 files changed, 9 insertions, 2 deletions
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 } |