]> git.ipfire.org Git - thirdparty/dracut.git/commit
fix(dracut.sh): --sysroot option broken if global variables not set in conf
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Thu, 29 Dec 2022 10:38:58 +0000 (11:38 +0100)
committerAntonio Álvarez Feijoo <antonio.feijoo@suse.com>
Thu, 2 Feb 2023 07:13:30 +0000 (08:13 +0100)
commit6f4a5c90ab993d2559720c2d4023d99ad43df00a
treeb6b9cf5f453cef2b885358144e7cf8dd718de6da
parent823de8fe5337cd7b8b4ce4dec3675ea44b723706
fix(dracut.sh): --sysroot option broken if global variables not set in conf

When `$dracutsysrootdir` is set and references an existing directory, the
internal global variables are never set, unless their value is assigned via
configuration file.

The simple fix would be turn all:

```
[[ -d $dracutsysrootdir$var ]] || var=value
```
into:
```
[[ -z $var || ! -d $dracutsysrootdir$var ]] && var=value
```

But this patch also includes a refactoring, removing duplicate code using the
same `set_global_var` function to set and export global variables, and improving
readability.
dracut.sh