From 517aa13913589f6e026e141c381896a876b6204e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Oct 2012 01:22:09 -0400 Subject: [PATCH] structural decomposition in partitionParams Avoids partial !! --- GitAnnexShell.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/GitAnnexShell.hs b/GitAnnexShell.hs index 4436ab3e1e..dc15a6ce85 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 (== '='))