Skip to content

Commit 66252f9

Browse files
committed
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.
1 parent 14e0111 commit 66252f9

6 files changed

Lines changed: 9 additions & 8 deletions

File tree

dracut-functions.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ get_blockdev_drv_through_sys() {
651651
while true; do
652652
if [[ -L "$_path"/driver/module ]]; then
653653
_mod=$(realpath "$_path"/driver/module)
654-
_mod=$(basename "$_mod")
654+
_mod="${_mod##*/}"
655655
_block_mods="$_block_mods $_mod"
656656
fi
657657
_path=$(dirname "$_path")
@@ -972,8 +972,8 @@ block_is_fcoe() {
972972
until [[ -d "$_dir/sys" ]]; do
973973
_dir="$_dir/.."
974974
if [[ -d "$_dir/subsystem" ]]; then
975-
subsystem=$(basename "$(readlink "$_dir"/subsystem)")
976-
[[ $subsystem == "fcoe" ]] && return 0
975+
subsystem=$(readlink "$_dir"/subsystem)
976+
[[ "${subsystem##*/}" == "fcoe" ]] && return 0
977977
fi
978978
done
979979
return 1

modules.d/45drm/module-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ installkernel() {
4646
for i in /sys/class/drm/privacy_screen-*/device/driver/module; do
4747
[[ -L $i ]] || continue
4848
modlink=$(readlink "$i")
49-
modname=$(basename "$modlink")
49+
modname="${modlink##*/}"
5050
hostonly=$(optional_hostonly) instmods "$modname"
5151
done
5252
else

modules.d/45simpledrm/module-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ installkernel() {
1717
for i in /sys/class/drm/privacy_screen-*/device/driver/module; do
1818
[[ -L $i ]] || continue
1919
modlink=$(readlink "$i")
20-
modname=$(basename "$modlink")
20+
modname="${modlink##*/}"
2121
hostonly='' instmods "$modname"
2222
done
2323
else

modules.d/45url-lib/url-lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ nfs_fetch_url() {
160160
mntdir="$(mkuniqdir /run nfs_mnt)"
161161
mount_nfs "$nfs:$server:$filepath${options:+:$options}" "$mntdir"
162162
# lazy unmount during pre-pivot hook
163-
inst_hook --hook pre-pivot --name 99url-lib-umount-nfs-"$(basename "$mntdir")" umount -l -- "$mntdir"
163+
inst_hook --hook pre-pivot --name 99url-lib-umount-nfs-"${mntdir##*/}" umount -l -- "$mntdir"
164164
fi
165165

166166
if [ -z "$outloc" ]; then

modules.d/71systemd-cryptsetup/module-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ install() {
121121
"the service unit may encounter a deadlock due to a circular dependency"
122122
fi
123123

124-
socket_unit_basename=$(basename "$socket_unit")
124+
socket_unit_basename="${socket_unit##*/}"
125125
inst_multiple -H -o \
126126
"$systemdsystemunitdir"/sockets.target.wants/"$socket_unit_basename" \
127127
"$systemdsystemconfdir"/sockets.target.wants/"$socket_unit_basename"

modules.d/74nvmf/module-setup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ installkernel() {
7676
if [[ $hostonly ]]; then
7777
for i in /sys/class/net/nbft*; do
7878
[ -d "$i" ] || continue
79-
_driver=$(basename "$(readlink -f "$i/device/driver/module")")
79+
_driver=$(readlink -f "$i/device/driver/module")
80+
_driver="${_driver##*/}"
8081
[ -z "$_driver" ] || instmods "$_driver"
8182
done
8283
fi

0 commit comments

Comments
 (0)