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.
This commit is contained in:
parent
df2639218a
commit
c8a6be7eef
1 changed files with 14 additions and 8 deletions
22
Git/Ssh.hs
22
Git/Ssh.hs
|
@ -34,7 +34,10 @@ type SshCommand = String
|
||||||
-- | Checks for GIT_SSH and GIT_SSH_COMMAND and if set, returns
|
-- | Checks for GIT_SSH and GIT_SSH_COMMAND and if set, returns
|
||||||
-- a command and parameters to run to ssh.
|
-- a command and parameters to run to ssh.
|
||||||
gitSsh :: SshHost -> Maybe SshPort -> SshCommand -> IO (Maybe (FilePath, [CommandParam]))
|
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
|
gsc <- getEnv gitSshCommandEnv
|
||||||
case gsc of
|
case gsc of
|
||||||
Just c
|
Just c
|
||||||
|
@ -42,24 +45,27 @@ gitSsh host mp cmd = do
|
||||||
-- when it contains spaces; otherwise it's
|
-- when it contains spaces; otherwise it's
|
||||||
-- treated the same as GIT_SSH
|
-- treated the same as GIT_SSH
|
||||||
| any isSpace c -> ret "sh"
|
| any isSpace c -> ret "sh"
|
||||||
[ [ Param "-c"
|
[ Param "-c"
|
||||||
, Param (shellcmd c gitps)
|
, Param (shellcmd c sshps)
|
||||||
]
|
|
||||||
]
|
]
|
||||||
| otherwise -> ret c [gitps]
|
| otherwise -> ret c sshps
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
gs <- getEnv gitSshEnv
|
gs <- getEnv gitSshEnv
|
||||||
case gs of
|
case gs of
|
||||||
Just c -> ret c [gitps]
|
Just c -> ret c sshps
|
||||||
Nothing -> return Nothing
|
Nothing -> return Nothing
|
||||||
where
|
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
|
gitps = map Param $ case mp of
|
||||||
Nothing -> [host, cmd]
|
Nothing -> [host, cmd]
|
||||||
Just p -> [host, "-p", show p, 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
|
-- The shell command to run with sh -c is constructed
|
||||||
-- this way, rather than using "$@" because there could be some
|
-- this way, rather than using "$@" because there could be some
|
||||||
-- unwanted parameters passed to the command, and this way they
|
-- unwanted parameters passed to the command, and this way they
|
||||||
|
|
Loading…
Add table
Reference in a new issue