diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-03-20 14:23:19 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-03-20 14:23:19 -0400 |
commit | fbf69ca7b3eee84c2284d260aa70f106ff9d6d57 (patch) | |
tree | 75ee1ef07fdff285242f106547141658cf4a33af /Git | |
parent | 2952e3d0e57327c69f4f9808d232d88f49df7e2c (diff) |
fix GIT_SSH_COMMAND -n parameter
It was being passed to sh, not to the command, oops. Noticed because it
broke the test suite on OSX, where sh -n silently does nothing. Would
also break on Linux when eg posh was being used as the shell; bash
ignores the -n.
This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'Git')
-rw-r--r-- | Git/Ssh.hs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Git/Ssh.hs b/Git/Ssh.hs index 7d6a305bb..206e72113 100644 --- a/Git/Ssh.hs +++ b/Git/Ssh.hs @@ -34,7 +34,10 @@ type SshCommand = String -- | Checks for GIT_SSH and GIT_SSH_COMMAND and if set, returns -- a command and parameters to run to ssh. gitSsh :: SshHost -> Maybe SshPort -> SshCommand -> IO (Maybe (FilePath, [CommandParam])) -gitSsh host mp cmd = do +gitSsh host mp cmd = gitSsh' host mp cmd [] + +gitSsh' :: SshHost -> Maybe SshPort -> SshCommand -> [CommandParam] -> IO (Maybe (FilePath, [CommandParam])) +gitSsh' host mp cmd extrasshparams = do gsc <- getEnv gitSshCommandEnv case gsc of Just c @@ -42,24 +45,27 @@ gitSsh host mp cmd = do -- when it contains spaces; otherwise it's -- treated the same as GIT_SSH | any isSpace c -> ret "sh" - [ [ Param "-c" - , Param (shellcmd c gitps) - ] + [ Param "-c" + , Param (shellcmd c sshps) ] - | otherwise -> ret c [gitps] + | otherwise -> ret c sshps Nothing -> do gs <- getEnv gitSshEnv case gs of - Just c -> ret c [gitps] + Just c -> ret c sshps Nothing -> return Nothing where - ret c ll = return $ Just (c, concat ll) + ret c l = return $ Just (c, l) - -- git passes exactly these parameters to the command + -- Git passes exactly these parameters to the ssh command. gitps = map Param $ case mp of Nothing -> [host, cmd] Just p -> [host, "-p", show p, cmd] + -- Passing any extra parameters to the ssh command may + -- break some commands. + sshps = extrasshparams ++ gitps + -- 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 |