Browse Source

dracut-gencmdline: fix regex quoting in findstoragedriver()

On my LVM system this changes the relevant output from "rd_NO_LVM" to
"rd_LVM_VG=alan-desktop.Linux"

Note that on my newer system, it now reaches moduledep() and complains.
I don't know enough awk to tell whose fault it is :).

    awk: line 2: function gensub never defined
    awk: line 2: function gensub never defined
    rd_NO_MD rd_NO_LVM rd_NO_LUKS LANG=en_GB.UTF-8 root=/dev/sda2

Both my systems (old ubuntu and debian unstable) agree that bash
regexes should not be quoted:

    $ [[ 'a' =~ a ]] && echo match
    match
    $ [[ 'a' =~ ^a$ ]] && echo match
    match
    $ [[ 'a' =~ '^a$' ]] && echo match
    $

(and yes, it is safe against globbing)

    $ touch 9
    $ echo [0-9]
    9
    $ [[ 1 =~ [0-9] ]] && echo match
    match
master
Alan Jenkins 16 years ago committed by Harald Hoyer
parent
commit
13425eb243
  1. 6
      dracut-gencmdline

6
dracut-gencmdline

@ -212,7 +212,7 @@ findstoragedriverinsys () {
sysfs=$(freadlink ${sysfs%/*}) sysfs=$(freadlink ${sysfs%/*})
fi fi


if [[ ! "$sysfs" =~ '^/sys/.*block/.*$' ]]; then if [[ ! "$sysfs" =~ ^/sys/.*block/.*$ ]]; then
#error "WARNING: $sysfs is a not a block sysfs path, skipping" #error "WARNING: $sysfs is a not a block sysfs path, skipping"
return return
fi fi
@ -223,12 +223,12 @@ findstoragedriverinsys () {
*) handleddevices="$handleddevices $sysfs" ;; *) handleddevices="$handleddevices $sysfs" ;;
esac esac


if [[ "$sysfs" =~ '^/sys/.*block/md[0-9]+$' ]]; then if [[ "$sysfs" =~ ^/sys/.*block/md[0-9]+$ ]]; then
local raid=${sysfs##*/} local raid=${sysfs##*/}
vecho "Found MDRAID component $raid" vecho "Found MDRAID component $raid"
handleraid $raid handleraid $raid
fi fi
if [[ "$sysfs" =~ '^/sys/.*block/dm-[0-9]+$' ]]; then if [[ "$sysfs" =~ ^/sys/.*block/dm-[0-9]+$ ]]; then
vecho "Found DeviceMapper component ${sysfs##*/}" vecho "Found DeviceMapper component ${sysfs##*/}"
handledm $(cat $sysfs/dev |cut -d : -f 1) $(cat $sysfs/dev |cut -d : -f 2) handledm $(cat $sysfs/dev |cut -d : -f 1) $(cat $sysfs/dev |cut -d : -f 2)
fi fi

Loading…
Cancel
Save