Skip to content

Commit

Permalink
fix(base): add missing str_replace to dracut-dev-lib.sh
Browse files Browse the repository at this point in the history
```
dracut-dev-lib.sh: line 92: str_replace: command not found
dracut-dev-lib.sh: line 98: /var/tmp/dracut.sabKZg/initramfs/initqueue/finished/devexists-.sh: No such file or directory
dracut-dev-lib.sh: line 83: /var/tmp/dracut.sabKZg/initramfs/emergency/80-.sh: No such file or directory
```
  • Loading branch information
haraldh committed May 18, 2021
1 parent 7275c6f commit 148e420
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules.d/99base/dracut-dev-lib.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
#!/bin/sh

# replaces all occurrences of 'search' in 'str' with 'replacement'
#
# str_replace str search replacement
#
# example:
# str_replace ' one two three ' ' ' '_'
str_replace() {
local in="$1"
local s="$2"
local r="$3"
local out=''

while [ "${in##*"$s"*}" != "$in" ]; do
chop="${in%%"$s"*}"
out="${out}${chop}$r"
in="${in#*"$s"}"
done
echo "${out}${in}"
}

# get a systemd-compatible unit name from a path
# (mimicks unit_name_from_path_instance())
dev_unit_name() {
Expand Down
1 change: 1 addition & 0 deletions modules.d/99base/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ install() {
export DRACUT_SYSTEMD=1
fi
export PREFIX="$initdir"
export hookdir=/lib/dracut/hooks

# shellcheck source=dracut-dev-lib.sh
. "$moddir/dracut-dev-lib.sh"
Expand Down

0 comments on commit 148e420

Please sign in to comment.