2 # Manipulate options in a .config file from the command line
8 Manipulate options in a .config file from the command line.
10 config options command ...
12 --enable|-e option Enable option
13 --disable|-d option Disable option
14 --module|-m option Turn option into a module
15 --set-str option string
16 Set option to "string"
17 --set-val option value
19 --state|-s option Print state of option (n,y,m,undef)
21 --enable-after|-E beforeopt option
22 Enable option directly after other option
23 --disable-after|-D beforeopt option
24 Disable option directly after other option
25 --module-after|-M beforeopt option
26 Turn option into module directly after other option
28 commands can be repeated multiple times
31 --file .config file to change (default .config)
33 config doesn't check the validity of the .config file. This is done at next
41 if [ "$ARG" = "" ] ; then
46 ARG="${ARG/${CONFIG_}/}"
52 local name=$1 new=$2 before=$3
54 name_re="^($name=|# $name is not set)"
55 before_re="^($before=|# $before is not set)"
56 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
57 sed -ri "/$before_re/a $new" "$FN"
58 elif grep -Eq "$name_re" "$FN"; then
59 sed -ri "s:$name_re.*:$new:" "$FN"
65 if [ "$1" = "--file" ]; then
67 if [ "$FN" = "" ] ; then
75 if [ "$1" = "" ] ; then
79 while [ "$1" != "" ] ; do
99 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
103 set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
107 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
111 # sed swallows one level of escaping, so we need double-escaping
112 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
117 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
122 if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
125 V="$(grep "^${CONFIG_}$ARG=" $FN)"
126 if [ $? != 0 ] ; then
129 V="${V/#${CONFIG_}$ARG=/}"
139 set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
143 set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
147 set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
150 # undocumented because it ignores --file (fixme)
152 yes "" | make oldconfig