2 # Manipulate options in a .config file from the command line
6 # If no prefix forced, use the default CONFIG_
7 CONFIG_
="${CONFIG_-CONFIG_}"
11 Manipulate options in a .config file from the command line.
13 $myname options command ...
15 --enable|-e option Enable option
16 --disable|-d option Disable option
17 --module|-m option Turn option into a module
18 --set-str option string
19 Set option to "string"
20 --set-val option value
22 --undefine|-u option Undefine option
23 --state|-s option Print state of option (n,y,m,undef)
25 --enable-after|-E beforeopt option
26 Enable option directly after other option
27 --disable-after|-D beforeopt option
28 Disable option directly after other option
29 --module-after|-M beforeopt option
30 Turn option into module directly after other option
32 commands can be repeated multiple times
35 --file config-file .config file to change (default .config)
36 --keep-case|-k Keep next symbols' case (dont' upper-case it)
38 $myname doesn't check the validity of the .config file. This is done at next
41 By default, $myname will upper-case the given symbol. Use --keep-case to keep
42 the case of all following symbols unchanged.
44 $myname uses 'CONFIG_' as the default symbol prefix. Set the environment
45 variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" $myname ...
52 if [ "$ARG" = "" ] ; then
57 ARG
="${ARG/${CONFIG_}/}"
60 if [ "$MUNGE_CASE" = "yes" ] ; then
61 ARG
="`echo $ARG | tr a-z A-Z`"
66 local name
=$1 new
=$2 before
=$3
68 name_re
="^($name=|# $name is not set)"
69 before_re
="^($before=|# $before is not set)"
70 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
71 sed -ri "/$before_re/a $new" "$FN"
72 elif grep -Eq "$name_re" "$FN"; then
73 sed -ri "s:$name_re.*:$new:" "$FN"
82 sed -ri "/^($name=|# $name is not set)/d" "$FN"
85 if [ "$1" = "--file" ]; then
87 if [ "$FN" = "" ] ; then
95 if [ "$1" = "" ] ; then
100 while [ "$1" != "" ] ; do
124 set_var
"${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
128 set_var
"${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
132 set_var
"${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
136 # sed swallows one level of escaping, so we need double-escaping
137 set_var
"${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
142 set_var
"${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
146 undef_var
"${CONFIG_}$ARG"
150 if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
153 V
="$(grep "^
${CONFIG_}$ARG=" $FN)"
154 if [ $?
!= 0 ] ; then
157 V
="${V/#${CONFIG_}$ARG=/}"
167 set_var
"${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
171 set_var
"${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
175 set_var
"${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
178 # undocumented because it ignores --file (fixme)
180 yes "" |
make oldconfig