sudo raspi-config to select the I2C option but it got into the config.txt file appended to the previous line. I since fixed that, but want to know what I did wrong or is it a bug?
Here's what the current version of raspi-config does (it's in the
sed $CONFIG -i -r -e "s/^((device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?)(=[^,]*)?/\1=$SETTING/" if ! grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?=[^,]*" $CONFIG; then printf "dtparam=i2c_arm=$SETTING\n" >> $CONFIG fi
sed command will change the line if it begins with
= then something ending with
grep line then checks for the same thing and if it's not there, adds it. Don't ask me why this isn't an if/else; efficiency is not a real concern here anyway.
So note that won't change or count a line that's been commented out.