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 --state|-s option Print state of option (n,y,m,undef)
22 --enable-after|-E beforeopt option
23 Enable option directly after other option
24 --disable-after|-D beforeopt option
25 Disable option directly after other option
26 --module-after|-M beforeopt option
27 Turn option into module directly after other option
29 commands can be repeated multiple times
32 --file config-file .config file to change (default .config)
33 --keep-case|-k Keep next symbols' case (dont' upper-case it)
35 config doesn't check the validity of the .config file. This is done at next
38 By default, config will upper-case the given symbol. Use --keep-case to keep
39 the case of all following symbols unchanged.
41 config uses 'CONFIG_' as the default symbol prefix. Set the environment
42 variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ...
49 if [ "$ARG" = "" ] ; then
54 ARG="${ARG/${CONFIG_}/}"
57 if [ "$MUNGE_CASE" = "yes" ] ; then
58 ARG="`echo $ARG | tr a-z A-Z`"
63 local name=$1 new=$2 before=$3
65 name_re="^($name=|# $name is not set)"
66 before_re="^($before=|# $before is not set)"
67 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
68 sed -ri "/$before_re/a $new" "$FN"
69 elif grep -Eq "$name_re" "$FN"; then
70 sed -ri "s:$name_re.*:$new:" "$FN"
76 if [ "$1" = "--file" ]; then
78 if [ "$FN" = "" ] ; then
86 if [ "$1" = "" ] ; then
91 while [ "$1" != "" ] ; do
116 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
120 set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
124 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
128 # sed swallows one level of escaping, so we need double-escaping
129 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
134 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
139 if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
142 V="$(grep "^${CONFIG_}$ARG=" $FN)"
143 if [ $? != 0 ] ; then
146 V="${V/#${CONFIG_}$ARG=/}"
156 set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
160 set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
164 set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
167 # undocumented because it ignores --file (fixme)
169 yes "" | make oldconfig