Skip to content

Commit f3441cc

Browse files
pvalenajohannbg
authored andcommitted
fix(10i18n): stop leaking shell options
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.
1 parent f63faaa commit f3441cc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

modules.d/10i18n/module-setup.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ install() {
3131
VCONFIG_CONF="/etc/vconsole.conf"
3232

3333
findkeymap() {
34-
# shellcheck disable=SC2064
35-
trap "$(shopt -p nullglob globstar)" RETURN
36-
shopt -q -s nullglob globstar
37-
3834
local -a MAPS
3935
local MAPNAME
4036
local INCLUDES
@@ -46,7 +42,10 @@ install() {
4642
MAPS=("$1")
4743
else
4844
MAPNAME=${1%.map*}
49-
MAPS=("$dracutsysrootdir""${kbddir}"/keymaps/**/"${MAPNAME}"{,.map{,.*}})
45+
46+
mapfile -t -d '' MAPS < <(
47+
find "${dracutsysrootdir}${kbddir}"/keymaps/ -type f \( -name "${MAPNAME}" -o -name "${MAPNAME}.map*" \) -print0
48+
)
5049
fi
5150

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

0 commit comments

Comments
 (0)