dracut icon indicating copy to clipboard operation
dracut copied to clipboard

Bash in POSIX mode

Open aafeijoo-suse opened this issue 2 years ago • 1 comments

localhost:~ # bash --version
GNU bash, version 4.4.23(1)-release (x86_64-suse-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
localhost:~ # export POSIXLY_CORRECT=y
localhost:~ # dracut -f
dracut: Executing: /usr/bin/dracut -f
/usr/lib/dracut/modules.d/00systemd/module-setup.sh: line 162: syntax error near unexpected token `<'
/usr/lib/dracut/modules.d/00systemd/module-setup.sh: line 162: `    mapfile -t _mods < <(modules_load_get /usr/lib/modules-load.d)'

Apparently some bashisms silently work with recent versions of Bash (tested ok > 5.1), but maybe we should workaround this issue for consistency. I see 2 options:

  1. unset POSIXLY_CORRECT at the beginning of dracut.sh.
  2. Also check [[ -n $POSIXLY_CORRECT ]] along with the Bash version, and exit in that case.

But if we decide to fix this, IMO the 2nd option is the best, because some scripts added by modules running at boot require bashisms.

aafeijoo-suse avatar Sep 21 '23 10:09 aafeijoo-suse

IMO better try to address the bashisms so that the generated initramfs can be used with dash or busybox.

bdrung avatar Apr 07 '24 00:04 bdrung