Skip to content

Commit

Permalink
fix(10i18n): stop leaking shell options
Browse files Browse the repository at this point in the history
Avoid using shell options in findkeymap, instead of using a wrapper[*]
to restore the previous options. Using mapfile and find to generate the list
of files also has the benefit of being more readable in this case.

[*] Reverted commit 3506476
Original issue description from Michal Hecko <mhecko@redhat.com>:

The findkeymap function manipulates the shell options and relies on
restoring them using the trap. However, as the function might be called
recursively, each recursive invocation changes the signal handler to its
own. As the recursion is entered with shell options already modified,
the changed trap handler is replaced with restoration to the modified
shell options, not the original ones.
  • Loading branch information
pvalena authored and johannbg committed Apr 4, 2022
1 parent f63faaa commit f3441cc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions modules.d/10i18n/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ install() {
VCONFIG_CONF="/etc/vconsole.conf"

findkeymap() {
# shellcheck disable=SC2064
trap "$(shopt -p nullglob globstar)" RETURN
shopt -q -s nullglob globstar

local -a MAPS
local MAPNAME
local INCLUDES
Expand All @@ -46,7 +42,10 @@ install() {
MAPS=("$1")
else
MAPNAME=${1%.map*}
MAPS=("$dracutsysrootdir""${kbddir}"/keymaps/**/"${MAPNAME}"{,.map{,.*}})

mapfile -t -d '' MAPS < <(
find "${dracutsysrootdir}${kbddir}"/keymaps/ -type f \( -name "${MAPNAME}" -o -name "${MAPNAME}.map*" \) -print0
)
fi

for MAP in "${MAPS[@]}"; do
Expand Down

0 comments on commit f3441cc

Please sign in to comment.