# Pastebin 4qFVq8oq Confirmed. The current regex [^ ]* only captures up to the first space, so keys with spaces produce an empty match — the script can never find or update those keys. The proposed fix s/^\(.*[^ ]\) *=.*/\1/p correctly extracts the full key name including spaces, and returns nothing for bare keys, empty lines, and comments. The current patch is not correct. The regex silently fails to extract keys with spaces — it returns empty for client quota, client oc size, and mon host. Since 3 of the 4 actual call sites use keys with spaces, the script will never match those existing keys to update them, and will append duplicates instead. $ echo "=== Current regex: s/^\([^ ]*\) *=.*/\1/p ===" $ echo 'key = value' | sed -n 's/^\([^ ]*\) *=.*/\1/p' key $ echo 'client quota = true' | sed -n 's/^\([^ ]*\) *=.*/\1/p' $ echo 'client oc size = 1048576' | sed -n 's/^\([^ ]*\) *=.*/\1/p' $ echo 'mon host = 192.168.1.1' | sed -n 's/^\([^ ]*\) *=.*/\1/p' Simple keys work, but keys with spaces (which are 3 of the 4 actual usages) return empty — so the [ "$cur_key" = "$key" ] comparison never matches and the key gets appended as a duplicate instead of updated