From 1898470b01f6ba8b2d3660ef438eae37e362c8de Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Wed, 22 Jul 2026 12:05:13 +0200 Subject: [PATCH] fix: remove basename calls https://dracut-ng.github.io/dracut/developer/bash.html says that `basename` should not be used. So replace the usage of `basename` by variable expansion instead. --- dracut-functions.sh | 6 +++--- modules.d/45drm/module-setup.sh | 2 +- modules.d/45simpledrm/module-setup.sh | 2 +- modules.d/45url-lib/url-lib.sh | 2 +- modules.d/71systemd-cryptsetup/module-setup.sh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dracut-functions.sh b/dracut-functions.sh index f162c27ee..0dd18e86a 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -651,7 +651,7 @@ get_blockdev_drv_through_sys() { while :; do if [[ -L "$_path"/driver/module ]]; then _mod=$(realpath "$_path"/driver/module) - _mod=$(basename "$_mod") + _mod="${_mod##*/}" _block_mods="$_block_mods $_mod" fi _path="${_path%/*}" @@ -972,8 +972,8 @@ block_is_fcoe() { until [[ -d "$_dir/sys" ]]; do _dir="$_dir/.." if [[ -d "$_dir/subsystem" ]]; then - subsystem=$(basename "$(readlink "$_dir"/subsystem)") - [[ $subsystem == "fcoe" ]] && return 0 + subsystem=$(readlink "$_dir"/subsystem) + [[ ${subsystem##*/} == "fcoe" ]] && return 0 fi done return 1 diff --git a/modules.d/45drm/module-setup.sh b/modules.d/45drm/module-setup.sh index 45a458681..17f7ebc2e 100755 --- a/modules.d/45drm/module-setup.sh +++ b/modules.d/45drm/module-setup.sh @@ -46,7 +46,7 @@ installkernel() { for i in /sys/class/drm/privacy_screen-*/device/driver/module; do [[ -L $i ]] || continue modlink=$(readlink "$i") - modname=$(basename "$modlink") + modname="${modlink##*/}" hostonly=$(optional_hostonly) instmods "$modname" done else diff --git a/modules.d/45simpledrm/module-setup.sh b/modules.d/45simpledrm/module-setup.sh index 7ce98ca41..0681b6aa5 100755 --- a/modules.d/45simpledrm/module-setup.sh +++ b/modules.d/45simpledrm/module-setup.sh @@ -17,7 +17,7 @@ installkernel() { for i in /sys/class/drm/privacy_screen-*/device/driver/module; do [[ -L $i ]] || continue modlink=$(readlink "$i") - modname=$(basename "$modlink") + modname="${modlink##*/}" hostonly='' instmods "$modname" done else diff --git a/modules.d/45url-lib/url-lib.sh b/modules.d/45url-lib/url-lib.sh index f8d5480f3..317db5a6c 100755 --- a/modules.d/45url-lib/url-lib.sh +++ b/modules.d/45url-lib/url-lib.sh @@ -160,7 +160,7 @@ nfs_fetch_url() { mntdir="$(mkuniqdir /run nfs_mnt)" mount_nfs "$nfs:$server:$filepath${options:+:$options}" "$mntdir" # lazy unmount during pre-pivot hook - inst_hook --hook pre-pivot --name 99url-lib-umount-nfs-"$(basename "$mntdir")" umount -l -- "$mntdir" + inst_hook --hook pre-pivot --name 99url-lib-umount-nfs-"${mntdir##*/}" umount -l -- "$mntdir" fi if [ -z "$outloc" ]; then diff --git a/modules.d/71systemd-cryptsetup/module-setup.sh b/modules.d/71systemd-cryptsetup/module-setup.sh index 65d729e60..4bad1effe 100755 --- a/modules.d/71systemd-cryptsetup/module-setup.sh +++ b/modules.d/71systemd-cryptsetup/module-setup.sh @@ -121,7 +121,7 @@ install() { "the service unit may encounter a deadlock due to a circular dependency" fi - socket_unit_basename=$(basename "$socket_unit") + socket_unit_basename="${socket_unit##*/}" inst_multiple -H -o \ "$systemdsystemunitdir"/sockets.target.wants/"$socket_unit_basename" \ "$systemdsystemconfdir"/sockets.target.wants/"$socket_unit_basename" -- 2.47.3