Correctly quote config values while saving

If the value contains a command (; or #) char or starts or ends with space it needs to be quoted.

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