2 # Manipulate options in a .config file from the command line
6 # If no prefix forced, use the default CONFIG_
7 CONFIG_
="${CONFIG_-CONFIG_}"
11 Manipulate options in a .config file from the command line.
13 $myname options command ...
15 --enable|-e option Enable option
16 --disable|-d option Disable option
17 --module|-m option Turn option into a module
18 --set-str option string
19 Set option to "string"
20 --set-val option value
22 --undefine|-u option Undefine option
23 --state|-s option Print state of option (n,y,m,undef)
25 --enable-after|-E beforeopt option
26 Enable option directly after other option
27 --disable-after|-D beforeopt option
28 Disable option directly after other option
29 --module-after|-M beforeopt option
30 Turn option into module directly after other option
32 commands can be repeated multiple times
35 --file config-file .config file to change (default .config)
36 --keep-case|-k Keep next symbols' case (dont' upper-case it)
38 $myname doesn't check the validity of the .config file. This is done at next
41 By default, $myname will upper-case the given symbol. Use --keep-case to keep
42 the case of all following symbols unchanged.
44 $myname uses 'CONFIG_' as the default symbol prefix. Set the environment
45 variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" $myname ...
52 if [ "$ARG" = "" ] ; then
57 ARG
="${ARG/${CONFIG_}/}"
60 if [ "$MUNGE_CASE" = "yes" ] ; then
61 ARG
="`echo $ARG | tr a-z A-Z`"
69 local tmpfile
="$infile.swp"
71 # sed append cmd: 'a\' + newline + text + newline
72 cmd
="$(printf "a
\\%b
$insert" "\n")"
74 sed -e "/$anchor/$cmd" "$infile" >"$tmpfile"
75 # replace original file with the edited one
76 mv "$tmpfile" "$infile"
83 local tmpfile
="$infile.swp"
85 sed -e "s/$before/$after/" "$infile" >"$tmpfile"
86 # replace original file with the edited one
87 mv "$tmpfile" "$infile"
93 local tmpfile
="$infile.swp"
95 sed -e "/$text/d" "$infile" >"$tmpfile"
96 # replace original file with the edited one
97 mv "$tmpfile" "$infile"
101 local name
=$1 new
=$2 before
=$3
103 name_re
="^($name=|# $name is not set)"
104 before_re
="^($before=|# $before is not set)"
105 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
106 txt_append
"^$before=" "$new" "$FN"
107 txt_append
"^# $before is not set" "$new" "$FN"
108 elif grep -Eq "$name_re" "$FN"; then
109 txt_subst
"^$name=.*" "$new" "$FN"
110 txt_subst
"^# $name is not set" "$new" "$FN"
119 txt_delete
"^$name=" "$FN"
120 txt_delete
"^# $name is not set" "$FN"
123 if [ "$1" = "--file" ]; then
125 if [ "$FN" = "" ] ; then
133 if [ "$1" = "" ] ; then
138 while [ "$1" != "" ] ; do
162 set_var
"${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
166 set_var
"${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
170 set_var
"${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
174 # sed swallows one level of escaping, so we need double-escaping
175 set_var
"${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
180 set_var
"${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
184 undef_var
"${CONFIG_}$ARG"
188 if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
191 V
="$(grep "^
${CONFIG_}$ARG=" $FN)"
192 if [ $?
!= 0 ] ; then
195 V
="${V/#${CONFIG_}$ARG=/}"
205 set_var
"${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
209 set_var
"${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
213 set_var
"${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
216 # undocumented because it ignores --file (fixme)
218 yes "" |
make oldconfig