Skip to content

Commit

Permalink
Tentative fix for FilePath regression
Browse files Browse the repository at this point in the history
  • Loading branch information
adinapoli committed Apr 1, 2022
1 parent 69fd6a5 commit c1dae8b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions shelly.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ extra-source-files:
test/data/zshrc
test/data/nonascii.txt
test/data/symlinked_dir/hoge_file
test/data/hello.sh
test/testall
README.md
ChangeLog.md
Expand Down
30 changes: 17 additions & 13 deletions src/Shelly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,26 @@ runCommand handles st exe args = findExe exe >>= \fullExe ->
#if defined(mingw32_HOST_OS)
fp
#else
_fp
fp
#endif
= do
mExe <- whichEith exe
case mExe of
Right execFp -> return execFp
-- windows looks in extra places besides the PATH, so just give
-- up even if the behavior is not properly specified anymore
--
-- non-Windows < 7.8 has a bug for read-only file systems
-- https://github.com/yesodweb/Shelly.hs/issues/56
-- it would be better to specifically detect that bug
= case fp of
-- If the 'FilePath' contains a more articulated path than just
-- an executable, don't try to find it.
'.' : _ -> return fp
_ -> do
mExe <- whichEith exe
case mExe of
Right execFp -> return execFp
-- windows looks in extra places besides the PATH, so just give
-- up even if the behavior is not properly specified anymore
--
-- non-Windows < 7.8 has a bug for read-only file systems
-- https://github.com/yesodweb/Shelly.hs/issues/56
-- it would be better to specifically detect that bug
#if defined(mingw32_HOST_OS)
Left _ -> return fp
Left _ -> return fp
#else
Left err -> liftIO $ throwIO $ userError err
Left err -> liftIO $ throwIO $ userError err
#endif


Expand Down
Empty file modified test/data/hello.sh
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions test/src/FindSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ findSpec = do
[ "dir"
, "dir/symlinked_dir"
, "dir/symlinked_dir/hoge_file"
, "hello.sh"
, "nonascii.txt"
, "symlinked_dir"
, "symlinked_dir/hoge_file"
Expand All @@ -128,6 +129,7 @@ findSpec = do
sort res @?=
[ "dir"
, "dir/symlinked_dir"
, "hello.sh"
, "nonascii.txt"
, "symlinked_dir"
, "symlinked_dir/hoge_file"
Expand Down
6 changes: 4 additions & 2 deletions test/src/RunSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ runSpec = do
then res @?= "Selbstverst\228ndlich \252berraschend\r\n"
else res @?= "Selbstverst\228ndlich \252berraschend\n"
it "script at $PWD" $ do
res <- shelly $ run "./test/data/hello.sh" []
res @?= "Hello!"
res <- shelly $ do
run "chmod" ["+x", "test/data/hello.sh"]
run "./test/data/hello.sh" []
res @?= "Hello!\n"

-- Bash-related commands
describe "bash" $ do
Expand Down

0 comments on commit c1dae8b

Please sign in to comment.