From 17be6b8b6663ac37e5b2f6caba2730ebd4f0f42f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 17 Mar 2017 18:06:59 -0400 Subject: super tricky shell command generation hack GIT_SSH_COMMAND was not working correctly with git-annex get, because when used in rsync -e, there were additional parameters appended at the end, which the GIT_SSH_COMMAND should not see. Fixed by constructing the shell command differently. This commit was supported by the NSF-funded DataLad project. --- Git/Ssh.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Git') diff --git a/Git/Ssh.hs b/Git/Ssh.hs index 79065f2b4..7d6a305bb 100644 --- a/Git/Ssh.hs +++ b/Git/Ssh.hs @@ -43,10 +43,8 @@ gitSsh host mp cmd = do -- treated the same as GIT_SSH | any isSpace c -> ret "sh" [ [ Param "-c" - , Param (c ++ " \"$@\"") - , Param c + , Param (shellcmd c gitps) ] - , gitps ] | otherwise -> ret c [gitps] Nothing -> do @@ -55,8 +53,16 @@ gitSsh host mp cmd = do Just c -> ret c [gitps] Nothing -> return Nothing where - -- git passes exactly these parameters + ret c ll = return $ Just (c, concat ll) + + -- git passes exactly these parameters to the command gitps = map Param $ case mp of Nothing -> [host, cmd] Just p -> [host, "-p", show p, cmd] - ret c ll = return $ Just (c, concat ll) + + -- The shell command to run with sh -c is constructed + -- this way, rather than using "$@" because there could be some + -- unwanted parameters passed to the command, and this way they + -- are ignored. For example, when Utility.Rsync.rsyncShell is + -- used, rsync adds some parameters after the command. + shellcmd c ps = c ++ " " ++ unwords (map shellEscape (toCommand ps)) -- cgit v1.2.3