Correctly quote config values while saving

If the value contains a command (; or #) char or starts or ends with space.

Signed-off-by: Sven Strickroth <email@cs-ware.de>