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 string
14 Set option to "string"
15 --set-val option value
17 --state|-s option Print state of option (n,y,m,undef)
19 --enable-after|-E beforeopt option
20 Enable option directly after other option
21 --disable-after|-D beforeopt option
22 Disable option directly after other option
23 --module-after|-M beforeopt option
24 Turn option into module directly after other option
26 commands can be repeated multiple times
29 --file .config file to change (default .config)
31 config doesn't check the validity of the .config file. This is done at next
39 if [ "$ARG" = "" ] ; then
50 local name=$1 new=$2 before=$3
52 name_re="^($name=|# $name is not set)"
53 before_re="^($before=|# $before is not set)"
54 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
55 sed -ri "/$before_re/a $new" "$FN"
56 elif grep -Eq "$name_re" "$FN"; then
57 sed -ri "s:$name_re.*:$new:" "$FN"
63 if [ "$1" = "--file" ]; then
65 if [ "$FN" = "" ] ; then
73 if [ "$1" = "" ] ; then
77 while [ "$1" != "" ] ; do
97 set_var "CONFIG_$ARG" "CONFIG_$ARG=y"
101 set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set"
105 set_var "CONFIG_$ARG" "CONFIG_$ARG=m"
109 # sed swallows one level of escaping, so we need double-escaping
110 set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\""
115 set_var "CONFIG_$ARG" "CONFIG_$ARG=$1"
120 if grep -q "# CONFIG_$ARG is not set" $FN ; then
123 V="$(grep "^CONFIG_$ARG=" $FN)"
124 if [ $? != 0 ] ; then
127 V="${V/#CONFIG_$ARG=/}"
137 set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A"
141 set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A"
145 set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A"
148 # undocumented because it ignores --file (fixme)
150 yes "" | make oldconfig