2 # Manipulate options in a .config file from the command line
4 # If no prefix forced, use the default CONFIG_
5 CONFIG_="${CONFIG_-CONFIG_}"
9 Manipulate options in a .config file from the command line.
11 config options command ...
13 --enable|-e option Enable option
14 --disable|-d option Disable option
15 --module|-m option Turn option into a module
16 --set-str option string
17 Set option to "string"
18 --set-val option value
20 --undefine|-u option Undefine option
21 --state|-s option Print state of option (n,y,m,undef)
23 --enable-after|-E beforeopt option
24 Enable option directly after other option
25 --disable-after|-D beforeopt option
26 Disable option directly after other option
27 --module-after|-M beforeopt option
28 Turn option into module directly after other option
30 commands can be repeated multiple times
33 --file config-file .config file to change (default .config)
34 --keep-case|-k Keep next symbols' case (dont' upper-case it)
36 config doesn't check the validity of the .config file. This is done at next
39 By default, config will upper-case the given symbol. Use --keep-case to keep
40 the case of all following symbols unchanged.
42 config uses 'CONFIG_' as the default symbol prefix. Set the environment
43 variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ...
50 if [ "$ARG" = "" ] ; then
55 ARG="${ARG/${CONFIG_}/}"
58 if [ "$MUNGE_CASE" = "yes" ] ; then
59 ARG="`echo $ARG | tr a-z A-Z`"
64 local name=$1 new=$2 before=$3
66 name_re="^($name=|# $name is not set)"
67 before_re="^($before=|# $before is not set)"
68 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
69 sed -ri "/$before_re/a $new" "$FN"
70 elif grep -Eq "$name_re" "$FN"; then
71 sed -ri "s:$name_re.*:$new:" "$FN"
80 sed -ri "/^($name=|# $name is not set)/d" "$FN"
83 if [ "$1" = "--file" ]; then
85 if [ "$FN" = "" ] ; then
93 if [ "$1" = "" ] ; then
98 while [ "$1" != "" ] ; do
122 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
126 set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
130 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
134 # sed swallows one level of escaping, so we need double-escaping
135 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
140 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
144 undef_var "${CONFIG_}$ARG"
148 if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
151 V="$(grep "^${CONFIG_}$ARG=" $FN)"
152 if [ $? != 0 ] ; then
155 V="${V/#${CONFIG_}$ARG=/}"
165 set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
169 set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
173 set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
176 # undocumented because it ignores --file (fixme)
178 yes "" | make oldconfig