2 # Manipulate options in a .config file from the command line
6 Manipulate options in a .config file from the command line.
8 config options command ...
10 --enable|-e option Enable option
11 --disable|-d option Disable option
12 --module|-m option Turn option into a module
13 --set-str option value
15 --state|-s option Print state of option (n,y,m,undef)
17 --enable-after|-E beforeopt option
18 Enable option directly after other option
19 --disable-after|-D beforeopt option
20 Disable option directly after other option
21 --module-after|-M beforeopt option
22 Turn option into module directly after other option
24 commands can be repeated multiple times
27 --file .config file to change (default .config)
29 config doesn't check the validity of the .config file. This is done at next
37 if [ "$ARG" = "" ] ; then
45 ARG
="`echo $ARG | tr a-z A-Z`"
49 local name
=$1 new
=$2 before
=$3
51 name_re
="^($name=|# $name is not set)"
52 before_re
="^($before=|# $before is not set)"
53 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
54 sed -ri "/$before_re/a $new" "$FN"
55 elif grep -Eq "$name_re" "$FN"; then
56 sed -ri "s:$name_re.*:$new:" "$FN"
62 if [ "$1" = "--file" ]; then
64 if [ "$FN" = "" ] ; then
72 if [ "$1" = "" ] ; then
76 while [ "$1" != "" ] ; do
96 set_var
"CONFIG_$ARG" "CONFIG_$ARG=y"
100 set_var
"CONFIG_$ARG" "# CONFIG_$ARG is not set"
104 set_var
"CONFIG_$ARG" "CONFIG_$ARG=m"
108 set_var
"CONFIG_$ARG" "CONFIG_$ARG=\"$1\""
113 if grep -q "# CONFIG_$ARG is not set" $FN ; then
116 V
="$(grep "^CONFIG_
$ARG=" $FN)"
117 if [ $?
!= 0 ] ; then
120 V
="${V/CONFIG_$ARG=/}"
128 set_var
"CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
132 set_var
"CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
136 set_var
"CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
139 # undocumented because it ignores --file (fixme)
141 yes "" |
make oldconfig