ALT Linux Bugzilla
– Attachment 5094 Details for
Bug 26122
Из строки достать значение.
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
shell-cmdline (v1)
shell-cmdline (text/plain), 1.57 KB, created by
Alexey Gladkov
on 2011-09-05 01:48:26 MSK
(
hide
)
Description:
shell-cmdline (v1)
Filename:
MIME Type:
Creator:
Alexey Gladkov
Created:
2011-09-05 01:48:26 MSK
Size:
1.57 KB
patch
obsolete
>#!/bin/sh -efu ># This file is covered by the GNU General Public License, ># which should be included with libshell as the file LICENSE. ># All copyright information are listed in the COPYING. > >if [ -z "${__included_shell_cmdline-}" ]; then >__included_shell_cmdline=1 > >. shell-string > ># Run handler for each variable in /proc/cmdline. ># >cmdline_foreach() { > local l="$1" h="$2" > local c= m= > > __is_set() { > [ $(( $1 & $2 )) -eq $2 ] > } > > fill_mask m "$l" > > local state=$((0x00)) > local VALUE=$((0x02)) > local EQUAL=$((0x04)) > local QUOTE=$((0x10)) > > local n= v= > > while [ -n "$l" ]; do > c="${l%$m}" > > case "$c" in > '"') > __is_set $state $QUOTE && > state=$(($state ^ $QUOTE)) || > state=$(($state | $QUOTE)) > ;; > ' ') > if __is_set $state $QUOTE; then > v="$v$c" > else > __is_set $state $EQUAL || > v=1 > $h "$n" "$v" || > break > n= v= > state=$((0x00)) > fi > ;; > '=') > ! __is_set $state $VALUE || > v="$v$c" > state=$(($state | $VALUE | $EQUAL)) > ;; > *) > if ! __is_set $state $VALUE; then > [ "$c" != '-' ] || c='_' > n="$n$c" > else > v="$v$c" > fi > ;; > esac > > l="${l#?}" > m="${m#?}" > done > unset __is_set >} > ># Find spicified variable in /proc/cmdline and store result into variable. ># ># Usage example: ># read cmdline < /proc/cmdline ># cmdline_get "$cmdline" 'initrd_value' 'initrd' ># echo "$initrd_value" >cmdline_get() { > local s="$1" retv="$2" getn="$3" > __getval() { > if [ "$1" = "$getn" ]; then > eval "$retv=\"$2\"" > return 1 > fi > } > cmdline_foreach "$s" __getval > unset __getval >} > >fi #__included_shell_cmdline
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 26122
: 5094