diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-03-17 18:06:59 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-03-17 18:06:59 -0400 |
commit | 17be6b8b6663ac37e5b2f6caba2730ebd4f0f42f (patch) | |
tree | 2f10fb5cd3451ddf2eb69502215de9f2c10e6ca3 /Git | |
parent | 3930d7a048fbd25fb7d058a08786d532e69927c2 (diff) |
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.
Diffstat (limited to 'Git')
-rw-r--r-- | Git/Ssh.hs | 16 |
1 files changed, 11 insertions, 5 deletions
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)) |