I am trying to parse /proc/cmdline in my initramfs using a case statement.
CMDLINE=`cat /proc/cmdline`
for param in $CMDLINE ; do
case "$param" in
root=*|init=*)
eval "$param"
;;
rescue)
escue="y"
;;
drive*)
echo -n $param
;;
esac
done
Now the problem is where I have drive*, I want to take multiple instances of drive from cmdline and parse them all into an array.
So /proc/cmdline might look like this.
/dev/mapper/Betsy-root vga=792 quiet=y opt2=bar opt1=bar op3=bar drive1="abcde:key.gpg" drive2="qrstuv:key2.gpg" drive3="foobar:false"
Problem is during the case statement when I do drive*) $param now looks like this.
drive1="abcde:key.gpg"drive2="qrstuv:key2.gpg"drive3="foobar:false"
So curious the best way to accomplish what I want. Which would be to dynamically create an array of drives. For example
drive[0]
drive[1]
drive[2]
What I tried doing was just looking for [a-zA-Z]" and inserting a new line. That way they would be split up and I could toss them into an array. Although I never had any luck getting that to work how I hoped. So with all that said...
Not knowing how many instances there will be in /proc/cmdline. how can I push each drive[0-9] into an array. Or maybe this is just a bad place for a case statement? Any advice would be appreciated.