dracutdevs / dracut

dracut the event driven initramfs infrastructure
https://github.com/dracutdevs/dracut/wiki
GNU General Public License v2.0
570 stars 396 forks source link

Bash in POSIX mode #2522

Open aafeijoo-suse opened 9 months ago

aafeijoo-suse commented 9 months ago
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.

bdrung commented 2 months ago

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