aboutsummaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-03-08 15:56:55 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-03-08 15:59:00 -0400
commit501881a6affdf9c5dc380eb14405e2363d7cc833 (patch)
treea1241fc62e8ea1b18a5b9260e625057f338d9e94 /Remote
parentdefe0afb45378ec54cb115f199e6352ee8695681 (diff)
Windows: Improve handling of shebang in external special remote program, searching for the program in the PATH.
findShellCommand needs a full path to a file in order to check it for a shebang on Windows. It was being run with only the base name of the external special remote program, which would only work when it was in the current directory. This is why users in https://github.com/DanielDent/git-annex-remote-rclone/pull/10 and elsewhere were complaining that the previous improvements to git-annex didn't make git-remote-rclone work on Windows. Also, reworked checkearlytermination, which while it worked, seemed to rely on a race condition. And, improved its error messages. This commit was sponsored by Shane-o on Patreon.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/External.hs20
1 files changed, 8 insertions, 12 deletions
diff --git a/Remote/External.hs b/Remote/External.hs
index b66e102a4..0ac381b8c 100644
--- a/Remote/External.hs
+++ b/Remote/External.hs
@@ -375,7 +375,8 @@ startExternal external = do
return st
where
start errrelayer g = liftIO $ do
- (cmd, ps) <- findShellCommand basecmd
+ cmdpath <- searchPath basecmd
+ (cmd, ps) <- maybe (pure (basecmd, [])) findShellCommand cmdpath
let basep = (proc cmd (toCommand ps))
{ std_in = CreatePipe
, std_out = CreatePipe
@@ -383,9 +384,8 @@ startExternal external = do
}
p <- propgit g basep
(Just hin, Just hout, Just herr, ph) <-
- createProcess p `catchIO` runerr
+ createProcess p `catchIO` runerr cmdpath
stderrelay <- async $ errrelayer herr
- checkearlytermination =<< getProcessExitCode ph
cv <- newTVarIO $ externalDefaultConfig external
pv <- newTVarIO Unprepared
pid <- atomically $ do
@@ -409,15 +409,11 @@ startExternal external = do
environ <- propGitEnv g
return $ p { env = Just environ }
- runerr _ = giveup ("Cannot run " ++ basecmd ++ " -- Make sure it's in your PATH and is executable.")
-
- checkearlytermination Nothing = noop
- checkearlytermination (Just exitcode) = ifM (inPath basecmd)
- ( giveup $ unwords [ "failed to run", basecmd, "(" ++ show exitcode ++ ")" ]
- , do
- path <- intercalate ":" <$> getSearchPath
- giveup $ basecmd ++ " is not installed in PATH (" ++ path ++ ")"
- )
+ runerr (Just cmd) _ =
+ giveup $ "Cannot run " ++ cmd ++ " -- Make sure it's executable and that its dependencies are installed."
+ runerr Nothing _ = do
+ path <- intercalate ":" <$> getSearchPath
+ giveup $ "Cannot run " ++ basecmd ++ " -- It is not installed in PATH (" ++ path ++ ")"
stopExternal :: External -> Annex ()
stopExternal external = liftIO $ do