From aaf07df79c65ff03995bd1acbe86930344ad70d9 Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sun, 25 Apr 2021 19:48:14 +0200 Subject: [PATCH 1/2] Cosmetic fixes --- install-zfs.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install-zfs.sh b/install-zfs.sh index ab9ad31..5d7bf49 100755 --- a/install-zfs.sh +++ b/install-zfs.sh @@ -342,7 +342,7 @@ function find_suitable_disks { candidate_disk_ids=$(find /dev/disk/by-id -regextype awk -regex '.+/(ata|nvme|scsi|mmc)-.+' -not -regex '.+-part[0-9]+$' | sort) mounted_devices="$(df | awk 'BEGIN {getline} {print $1}' | xargs -n 1 lsblk -no pkname 2> /dev/null | sort -u || true)" - while read -r disk_id || [[ -n "$disk_id" ]]; do + while read -r disk_id || [[ -n $disk_id ]]; do local device_info local block_device_basename @@ -370,7 +370,6 @@ function find_suitable_disks { $(udevadm info --query=property "$(readlink -f "$disk_id")") LOG - done < <(echo -n "$candidate_disk_ids") if [[ ${#v_suitable_disks[@]} -eq 0 ]]; then From cf57572a6bb21b3ed9edf30ba36657a7a6b2f395 Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sun, 25 Apr 2021 20:21:09 +0200 Subject: [PATCH 2/2] Sort disks in selection dialog --- install-zfs.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install-zfs.sh b/install-zfs.sh index 5d7bf49..298fcdd 100755 --- a/install-zfs.sh +++ b/install-zfs.sh @@ -471,11 +471,16 @@ function select_disks { local disk_selection_status=OFF fi + # St00pid simple way of sorting by block device name. Relies on the tokens not including whitespace. + for disk_id in "${v_suitable_disks[@]}"; do block_device_basename="$(basename "$(readlink -f "$disk_id")")" - menu_entries_option+=("$disk_id" "($block_device_basename)" "$disk_selection_status") + menu_entries_option+=("$disk_id ($block_device_basename) $disk_selection_status") done + # shellcheck disable=2207 # cheating here, for simplicity (alternative: add tr and mapfile). + menu_entries_option=($(printf $'%s\n' "${menu_entries_option[@]}" | sort -k 2)) + local dialog_message="Select the ZFS devices. Devices with mounted partitions, cdroms, and removable devices are not displayed!