summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-03-13 16:20:52 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-03-13 16:20:52 -0400
commitc1eaab9192a1808d3acc13bfdaf094a28346d909 (patch)
treec850b984148772fc1a34905f66ffe7976ef1edba
parentb55c32d4c6cb63ffd6d9ce49eee8be95628c9746 (diff)
Windows: Fix bug in shell script shebang lookup code that caused a "delayed read on closed handle" error.
The bug was that withFile closes the handle afterwards, but the content of the file was not read due to laziness. Using readFile avoids it. This commit was sponsored by Nick Daly on Patreon.
-rw-r--r--CHANGELOG2
-rw-r--r--Utility/Shell.hs3
-rw-r--r--doc/bugs/external_remote_hGetContents_handle_error.mdwn2
3 files changed, 5 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a8dd88269..443adb64d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,8 @@ git-annex (6.20170301.2) UNRELEASED; urgency=medium
program, searching for the program in the PATH.
* Drop support for building with old versions of dns, http-conduit,
directory, feed, and http-types.
+ * Windows: Fix bug in shell script shebang lookup code that
+ caused a "delayed read on closed handle" error.
-- Joey Hess <id@joeyh.name> Thu, 02 Mar 2017 12:51:40 -0400
diff --git a/Utility/Shell.hs b/Utility/Shell.hs
index 116ab6164..b8a9491dc 100644
--- a/Utility/Shell.hs
+++ b/Utility/Shell.hs
@@ -49,8 +49,7 @@ findShellCommand f = do
#ifndef mingw32_HOST_OS
defcmd
#else
- l <- catchDefaultIO Nothing $ withFile f ReadMode $
- headMaybe . lines <$$> hGetContents
+ l <- catchDefaultIO Nothing $ headMaybe . lines <$> readFile f
case l of
Just ('#':'!':rest) -> case words rest of
[] -> defcmd
diff --git a/doc/bugs/external_remote_hGetContents_handle_error.mdwn b/doc/bugs/external_remote_hGetContents_handle_error.mdwn
index 33914f924..a3414780f 100644
--- a/doc/bugs/external_remote_hGetContents_handle_error.mdwn
+++ b/doc/bugs/external_remote_hGetContents_handle_error.mdwn
@@ -40,3 +40,5 @@ Same as before, windows, git-bash
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
Thanks for the quick response earlier. I hope this is helpful information. Keep up the great work! :)
+
+> Reproduced this bug, and I've committed a fix. [[done]] --[[Joey]]