Sweep across the three script directories: features/scripts/utils,
core/system/scripts, themes/engine/scripts. 142 of 169 bash scripts
gained `set -e`; 27 already had it; the one Python helper
(nomarchy-haptic-touchpad) was skipped via shebang detection.
Why: bash's default behavior is to continue past a failed command,
which means a script that does "do A; do B; do C" leaves the system
in a half-applied state when B fails - and the user gets no signal.
Several recent fix commits (theme partial-apply, waybar reload race,
installer prewipe silent failures) all trace back to this. set -e
turns silent corruption into a loud abort the user can act on.
The 11 scripts with explicit `|| true` markers stay safe under set -e
because || true coerces the exit to zero; the markers continue to
mean "I deliberately tolerate this failure here."
Deliberate exception: nomarchy-menu runs WITHOUT set -e. It is an
interactive UX loop where action branches do `cmd; back_to <self>`
so a failed action would abort the script under set -e and the menu
would disappear without feedback. Soft-failure - menu re-displays,
user picks again - is the right semantic. Documented inline.
Validation: bash -n on every modified script (zero failures). The
new pre-commit hook (27f5663) was just updated to filter by shebang
so it doesn't try to bash-syntax-check the Python helper - that
filter was uncovered by this sweep.
Risk: set -e can surface latent bugs in scripts that previously
relied on silent continuation. If anything breaks, it's a real bug
that was already broken and is now visible. Easy per-script revert
if any UX glitches show up.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
51 lines
1.3 KiB
Bash
Executable File
51 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Returns drive information about a given volumne, like /dev/nvme0, which is used by nomarchy-drive-select.
|
|
|
|
if (($# == 0)); then
|
|
echo "Usage: nomarchy-drive-info [/dev/drive]"
|
|
exit 1
|
|
else
|
|
drive="$1"
|
|
fi
|
|
|
|
# Find the root drive in case we are looking at partitions
|
|
root_drive=$(lsblk -no PKNAME "$drive" 2>/dev/null | tail -n1)
|
|
if [[ -n $root_drive ]]; then
|
|
root_drive="/dev/$root_drive"
|
|
else
|
|
root_drive="$drive"
|
|
fi
|
|
|
|
# Get basic disk information
|
|
size=$(lsblk -dno SIZE "$drive" 2>/dev/null)
|
|
vendor=$(lsblk -dno VENDOR "$root_drive" 2>/dev/null | sed 's/ *$//')
|
|
model=$(lsblk -dno MODEL "$root_drive" 2>/dev/null | sed 's/ *$//')
|
|
|
|
# Combine vendor and model, avoiding duplication
|
|
label=""
|
|
if [[ -n $vendor && -n $model ]]; then
|
|
if [[ $model == *$vendor* ]]; then
|
|
label="$model"
|
|
else
|
|
label="$vendor $model"
|
|
fi
|
|
elif [[ -n $model ]]; then
|
|
label="$model"
|
|
elif [[ -n $vendor ]]; then
|
|
label="$vendor"
|
|
fi
|
|
|
|
# Format display string
|
|
display="$drive"
|
|
[[ -n $size ]] && display="$display ($size)"
|
|
[[ -n $label ]] && display="$display - $label"
|
|
|
|
# Append compact partition summary
|
|
part_summary=$(lsblk -nro TYPE,NAME,FSTYPE,MOUNTPOINT "$root_drive" 2>/dev/null | \
|
|
awk '$1=="part" { printf "%s%s%s", s, ($3==""?"unknown":$3), ($4==""?"":"("$4")"); s=", " }')
|
|
[[ -n $part_summary ]] && display+=" [$part_summary]"
|
|
|
|
echo "$display"
|