From c3bd4a86ae32f0292ae9db3cf98c938f20406bc5 Mon Sep 17 00:00:00 2001 From: Toni Nowak <58035493+acidkill@users.noreply.github.com> Date: Fri, 7 Aug 2026 15:43:45 +0200 Subject: [PATCH] Fix unbound XKBLAYOUT under set -u in the keyboard-layout migration (#6539) * Fix unbound XKBLAYOUT under set -u in the keyboard-layout migration /etc/vconsole.conf only guarantees KEYMAP -- XKBLAYOUT is written by some installers but not required, and vconsole.conf on a stock install may not define it at all. omarchy-migrate runs every migration with set -euo pipefail, so referencing the unset variable directly aborted the migration run instead of just skipping a layout this migration doesn't care about. Read it with a default-empty expansion first, then apply the existing comma-strip separately -- keeps both failure modes (unset, and set with a trailing keymap variant) handled explicitly instead of folding them into one expansion that only covers one of the two. * Survive a missing vconsole.conf in the keyboard-layout migration Defaulting XKBLAYOUT fixed the unset variable but not the other way this line takes the migration chain down. `.` fails when /etc/vconsole.conf is not there at all, `&&` short-circuits, and the non-zero status leaves the command substitution and kills the assignment under omarchy-migrate's `bash -euo pipefail` -- the same abort, one branch over. The file is optional enough that both other readers of it, omarchy_hooks.conf and 1781485962.sh, guard with `-f` first. Run the echo unconditionally so the substitution reports its status instead of the source's. Read both paths from the environment, the way the zram migration already does, and cover the layout cases plus both crashes with a test. Co-Authored-By: Claude Opus 5 (1M context) * Read the keyboard layout from vconsole.conf alone Two ways the layout could come from somewhere other than the file, both found reviewing the fix before it: Sourcing does not clear an exported XKBLAYOUT, so on a machine that exports one, a vconsole.conf that sets no layout -- or none at all -- left the caller's environment deciding what the initramfs bundles. Unset it in the subshell so only the file can answer. Skipping the source when the file is missing, rather than letting the substitution swallow the failure, also stops depending on errexit being discarded inside command substitution. inherit_errexit takes that back and the chain aborts again; nothing in Omarchy sets it today, but the other two readers of vconsole.conf already check `-f` first and this now matches. Test the layout list past its one Cyrillic entry, both orders of a comma-separated pair, an exported XKBLAYOUT, and inherit_errexit. Each of those catches a mutation that survived before. Co-Authored-By: Claude Opus 5 (1M context) * Drop the test scaffolding from the keyboard-layout migration A migration runs once and then gets deleted, so a suite entry for this one is upkeep with a short shelf life. The path overrides existed only so that test could aim the migration at fixtures; with the test gone they are indirection nothing exercises, so both go back to literal paths. The fixes stay: check the file before sourcing it, unset XKBLAYOUT so an exported one cannot answer for a file that sets none, and strip the keymap variant before matching. Co-Authored-By: Claude Opus 5 (1M context) --------- Co-authored-by: Toni Nowak Co-authored-by: David Heinemeier Hansson Co-authored-by: Claude Opus 5 (1M context) --- migrations/1784476564.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/migrations/1784476564.sh b/migrations/1784476564.sh index 1de97cd4..bef374a9 100644 --- a/migrations/1784476564.sh +++ b/migrations/1784476564.sh @@ -8,7 +8,13 @@ echo "Keep non-Latin keyboard layouts out of the initramfs so the LUKS passphras hooks_conf="/etc/mkinitcpio.conf.d/omarchy_hooks.conf" -layout=$(. /etc/vconsole.conf 2>/dev/null && echo "${XKBLAYOUT%%,*}") +# vconsole.conf only guarantees KEYMAP, and it need not exist at all. Sourcing +# one that isn't there fails, and under omarchy-migrate's `bash -euo pipefail` +# that aborts every migration behind this one. Unset first so an exported +# XKBLAYOUT can't answer for a file that sets none. +layout="" +[[ -f /etc/vconsole.conf ]] && layout=$(unset XKBLAYOUT; . /etc/vconsole.conf; echo "${XKBLAYOUT:-}") +layout="${layout%%,*}" if [[ $layout =~ ^(af|am|ara|bd|bg|by|et|ge|gr|il|in|iq|ir|kg|kh|kz|la|lk|mk|mm|mn|mv|np|rs|ru|sy|th|tj|ua)$ ]] && [[ -f $hooks_conf ]] && grep -qx 'FILES+=(/etc/vconsole.conf)' "$hooks_conf"; then