fix(iso): Don't store subshell error msgs in vars, exit completely (#1)
This commit is contained in:
parent
61cffda88b
commit
d5f6e62b56
20
setup.sh
20
setup.sh
@ -7,6 +7,10 @@ declare zpool_name zfs_arch_dataset_name
|
||||
zpool_name='zpool'
|
||||
zfs_arch_dataset_name='archlinux'
|
||||
|
||||
# https://unix.stackexchange.com/a/48550
|
||||
set -E
|
||||
trap '[ "$?" -ne 77 ] || exit 77' ERR
|
||||
|
||||
function set_ntp () {
|
||||
timedatectl set-ntp true
|
||||
}
|
||||
@ -56,8 +60,8 @@ function get_parts () {
|
||||
parts="$(get_partitions | jq --raw-output '.[][] | select(.parttype=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b") | .path')" || exit 1
|
||||
;;
|
||||
*)
|
||||
printf -- '%s\n' 'Unknown partition type '"'"'"${parttype}"'"'"', exiting 1 ...'
|
||||
exit 1
|
||||
>2 printf -- '%s\n' 'Unknown partition type '"'"'"${parttype}"'"'"', exiting 1 ...'
|
||||
exit 77
|
||||
;;
|
||||
esac
|
||||
printf -- '%s' "${parts}"
|
||||
@ -72,8 +76,8 @@ function we_have_exactly_one_part () {
|
||||
if [[ "$(wc -c <<<"${parts_list}")" -gt '1' ]]; then
|
||||
case "${parts_count}" in
|
||||
0)
|
||||
printf -- '%s\n' 'No '"${parttype^^}"' partition found. Exiting 1 ...'
|
||||
exit 1
|
||||
>2 printf -- '%s\n' 'No '"${parttype^^}"' partition found. Exiting 1 ...'
|
||||
exit 77
|
||||
;;
|
||||
1)
|
||||
return 0
|
||||
@ -82,8 +86,8 @@ function we_have_exactly_one_part () {
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
printf -- '%s\n' 'Partition list does not look valid. Cowardly exiting 1 ...'
|
||||
exit 1
|
||||
>2 printf -- '%s\n' 'Partition list does not look valid. Cowardly exiting 1 ...'
|
||||
exit 77
|
||||
fi
|
||||
}
|
||||
|
||||
@ -94,8 +98,8 @@ function get_drive_id () {
|
||||
printf -- '%s' "${drive_id}"
|
||||
return 0
|
||||
fi
|
||||
printf -- '%s\n' 'Not exactly one '"'${1:?}'"' partition entry in /dev/disk/by-id, exiting 1 ...'
|
||||
exit 1
|
||||
>2 printf -- '%s\n' 'Not exactly one '"'${1:?}'"' partition entry in /dev/disk/by-id, exiting 1 ...'
|
||||
exit 77
|
||||
}
|
||||
|
||||
function select_part () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user