diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-16 01:22:09 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-16 01:22:09 -0400 |
commit | e40f0dfd3407541c81a2d1e204617926153abad4 (patch) | |
tree | c9b5f79debf287440a7f41b09633e3e5635c435d /GitAnnexShell.hs | |
parent | f7184fb3ccec25e63d0a2d884e906c6b0a083d99 (diff) |
structural decomposition in partitionParams
Avoids partial !!
Diffstat (limited to 'GitAnnexShell.hs')
-rw-r--r-- | GitAnnexShell.hs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/GitAnnexShell.hs b/GitAnnexShell.hs index 4436ab3e1..dc15a6ce8 100644 --- a/GitAnnexShell.hs +++ b/GitAnnexShell.hs @@ -104,12 +104,10 @@ external params = do - rsync and not be useful. -} partitionParams :: [String] -> ([String], [String]) -partitionParams params - | null segments = ([], []) - | length segments < 2 = (segments !! 0, []) - | otherwise = (segments !! 0, segments !! 1) - where - segments = segment (== "--") params +partitionParams ps = case segment (== "--") ps of + params:fieldparams:_ -> (params, fieldparams) + [params] -> (params, []) + _ -> ([], []) parseFields :: [String] -> [(String, String)] parseFields = map (separate (== '=')) |