Improve ~/.ssh/config modification code to not add trailing spaces to lines it cannot parse.

"Host\n" is a valid line, and actually gets parsed ok, but this also holds
for other lines that it fails to parse for some reason.
This commit is contained in:
Joey Hess 2015-09-22 12:06:10 -04:00
parent 927498a1e4
commit 1dcb86498e
4 changed files with 17 additions and 1 deletions

View file

@ -82,7 +82,8 @@ genSshConfig = unlines . concatMap gen
gen (GlobalConfig s) = [setting s]
gen (HostConfig h cs) = ("Host " ++ h) : map (either comment setting) cs
setting (SshSetting indent k v) = indent ++ k ++ " " ++ v
setting (SshSetting indent k v) = indent ++ k ++
if null v then "" else " " ++ v
comment (Comment indent c) = indent ++ c
findHostConfigKey :: SshConfig -> Key -> Maybe Value