commit:     1cb44092fce298004ab4c4547c6fbcac29c5997f
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 23 18:50:33 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Feb 24 00:16:15 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1cb44092

sh/rc-functions.sh.in: add get_bootparam_value function

 sh/rc-functions.sh.in | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/sh/rc-functions.sh.in b/sh/rc-functions.sh.in
index 12eb4e2a..7b771f82 100644
--- a/sh/rc-functions.sh.in
+++ b/sh/rc-functions.sh.in
@@ -85,6 +85,40 @@ get_bootparam()
        return 1
 }
 
+get_bootparam_value()
+{
+       local match="$1" which_value="$2" sep="$3" result value
+       if [ -n "$match" -a -r /proc/cmdline ]; then
+               set -- $(cat /proc/cmdline)
+               while [ -n "$1" ]; do
+                       case "$1" in
+                               $match=*)
+                                       value="${1##*=}"
+                                       case "$which_value" in
+                                               all)
+                                                       [ -z "$sep" ] && sep=' '
+                                                       if [ -z "$result" ]; 
then
+                                                               result="$value"
+                                                       else
+                                                               
result="${result}${sep}${value}"
+                                                       fi
+                                                       ;;
+                                               last)
+                                                       result="$value"
+                                                       ;;
+                                               *)
+                                                       result="$value"
+                                                       break
+                                                       ;;
+                                       esac
+                                       ;;
+                       esac
+                       shift
+               done
+       fi
+       echo $result
+}
+
 # Called from openrc-run.sh or gendepends.sh
 _get_containers() {
        local c

Reply via email to