CC=abc lights := on compile_today: true
setconf can change the values to something else. It will take the first key it finds and change the value.
setconf can also change values that span over multiple lines, by adding an end string as the last parameter. A typical end string would be ')' or ']'.
You are writing a PKGBUILD for Arch and wish to change a setting without using sed.
Let's say you want to change CC from abc to gcc and that "CC=gcc make" doesn't cut it, for some reason.
Then you can use the following command:
setconf Makefile CC gcc
Setting a value:
sed -i filename 's/key=oldvalue/key=value/g'vs
setconf filename key value
Setting a value, adding the key and value if missing and creating the file if missing:
grep -q 'x=' file 2>/dev/null && sed 's/x=.*/x=7/g' -i file || echo 'x=7' >> filevs
setconf -a file x=7
The old value may have to be provided when performing replacements with sed.
Also note that the example using sed will not handle variations in whitespace or in choice of assignment symbol.
setconf supports ==, =>, =, :=, :: and :.
git clone https://github.com/xyproto/setconf
pacman -S setconf
pkgin install py27-setconf
cd /usr/pkgsrc/sysutils/py-setconf && make install
emerge -av setconf
zypper install setconf
It's recommended to install setconf with your distros package management system.
Here is a quick, manual way of installing the latest version of setconf:
curl -s https://setconf.roboticoverlords.org/setconf-0.7.7.tar.xz | tar JxC /tmp sudo install -Dm755 /tmp/setconf-0.7.7/setconf.py /usr/bin/setconf sudo install -Dm644 /tmp/setconf-0.7.7/setconf.1.gz /usr/share/man/man1/setconf.1.gz
Run the two last commands as root instead of with sudo, if you prefer.