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 --state|-s option Print state of option (n,y,m,undef)
15 --enable-after|-E beforeopt option
16 Enable option directly after other option
17 --disable-after|-D beforeopt option
18 Disable option directly after other option
19 --module-after|-M beforeopt option
20 Turn option into module directly after other option
22 commands can be repeated multiple times
25 --file .config file to change (default .config)
27 config doesn't check the validity of the .config file. This is done at next
35 if [ "$ARG" = "" ] ; then
43 ARG="`echo $ARG | tr a-z A-Z`"
47 local name=$1 new=$2 before=$3
49 name_re="^($name=|# $name is not set)"
50 before_re="^($before=|# $before is not set)"
51 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
52 sed -ri "/$before_re/a $new" "$FN"
53 elif grep -Eq "$name_re" "$FN"; then
54 sed -ri "s:$name_re.*:$new:" "$FN"
60 if [ "$1" = "--file" ]; then
62 if [ "$FN" = "" ] ; then
70 if [ "$1" = "" ] ; then
74 while [ "$1" != "" ] ; do
94 set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
98 set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
102 set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
106 if grep -q "# CONFIG_$ARG is not set" $FN ; then
109 V="$(grep "^CONFIG_$ARG=" $FN)"
110 if [ $? != 0 ] ; then
113 V="${V/CONFIG_$ARG=/}"
121 set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
125 set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
129 set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
132 # undocumented because it ignores --file (fixme)
134 yes "" | make oldconfig