diff options
| author | Craig Jennings <c@cjennings.net> | 2026-02-23 06:05:25 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-02-23 06:05:25 -0600 |
| commit | 1268a283526ca4b1d11d391ede944f055b4abafd (patch) | |
| tree | 6c9c7be13b834e75246ecd60a3e0b456982df416 | |
| parent | 2b842fcd47ac24b9da7f192f64b78f83e8fc45af (diff) | |
| download | archangel-1268a283526ca4b1d11d391ede944f055b4abafd.tar.gz archangel-1268a283526ca4b1d11d391ede944f055b4abafd.zip | |
fix: resolve SC2155 shellcheck warnings in custom/lib/
Declare and assign local variables separately to avoid masking
return values from command substitutions.
| -rw-r--r-- | custom/lib/common.sh | 9 | ||||
| -rw-r--r-- | custom/lib/disk.sh | 6 | ||||
| -rw-r--r-- | custom/lib/zfs.sh | 12 |
3 files changed, 18 insertions, 9 deletions
diff --git a/custom/lib/common.sh b/custom/lib/common.sh index 3af5707..0f02e37 100644 --- a/custom/lib/common.sh +++ b/custom/lib/common.sh @@ -31,7 +31,8 @@ prompt() { echo -e "${BLUE}$1${NC}"; } # Log to file if LOG_FILE is set log() { - local msg="[$(date +'%Y-%m-%d %H:%M:%S')] $1" + local msg + msg="[$(date +'%Y-%m-%d %H:%M:%S')] $1" if [[ -n "$LOG_FILE" ]]; then echo "$msg" >> "$LOG_FILE" fi @@ -162,8 +163,10 @@ list_available_disks() { for disk in /dev/nvme[0-9]n[0-9] /dev/sd[a-z] /dev/vd[a-z]; do [[ -b "$disk" ]] || continue disk_in_use "$disk" && continue - local size=$(get_disk_size "$disk") - local model=$(get_disk_model "$disk") + local size + size=$(get_disk_size "$disk") + local model + model=$(get_disk_model "$disk") disks+=("$disk ($size, $model)") done printf '%s\n' "${disks[@]}" diff --git a/custom/lib/disk.sh b/custom/lib/disk.sh index 38c6dd9..2e7deb3 100644 --- a/custom/lib/disk.sh +++ b/custom/lib/disk.sh @@ -111,7 +111,8 @@ format_efi_partitions() { local first=true for disk in "${disks[@]}"; do - local efi=$(get_efi_partition "$disk") + local efi + efi=$(get_efi_partition "$disk") if $first; then format_efi "$efi" "EFI" first=false @@ -162,7 +163,8 @@ select_disks() { # Extract just the device paths (remove size/model info) SELECTED_DISKS=() while IFS= read -r line; do - local disk=$(echo "$line" | cut -d' ' -f1) + local disk + disk=$(echo "$line" | cut -d' ' -f1) SELECTED_DISKS+=("$disk") done <<< "$selected" diff --git a/custom/lib/zfs.sh b/custom/lib/zfs.sh index 7862f0d..bb948fb 100644 --- a/custom/lib/zfs.sh +++ b/custom/lib/zfs.sh @@ -104,7 +104,8 @@ create_zfs_datasets() { zfs create -o mountpoint=none -o canmount=off "$POOL_NAME/ROOT" # Calculate reservation (20% of pool, capped 5-20G) - local pool_size_bytes=$(zpool get -Hp size "$POOL_NAME" | awk '{print $3}') + local pool_size_bytes + pool_size_bytes=$(zpool get -Hp size "$POOL_NAME" | awk '{print $3}') local pool_size_gb=$((pool_size_bytes / 1024 / 1024 / 1024)) local reserve_gb=$((pool_size_gb / 5)) [[ $reserve_gb -gt 20 ]] && reserve_gb=20 @@ -152,7 +153,8 @@ configure_zfsbootmenu() { if [[ ! -f /etc/hostid ]]; then zgenhostid fi - local host_id=$(hostid) + local host_id + host_id=$(hostid) # Copy hostid to installed system cp /etc/hostid /mnt/etc/hostid @@ -205,9 +207,11 @@ configure_zfsbootmenu() { done # Set as primary boot option - local bootnum=$(efibootmgr | grep "ZFSBootMenu" | head -1 | grep -oP 'Boot\K[0-9A-F]+') + local bootnum + bootnum=$(efibootmgr | grep "ZFSBootMenu" | head -1 | grep -oP 'Boot\K[0-9A-F]+') if [[ -n "$bootnum" ]]; then - local current_order=$(efibootmgr | grep "BootOrder" | cut -d: -f2 | tr -d ' ') + local current_order + current_order=$(efibootmgr | grep "BootOrder" | cut -d: -f2 | tr -d ' ') efibootmgr --bootorder "$bootnum,$current_order" --quiet info "ZFSBootMenu set as primary boot option" fi |
