summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/ghci/Linker.hs19
-rw-r--r--testsuite/tests/rts/Makefile4
-rw-r--r--testsuite/tests/rts/all.T1
3 files changed, 18 insertions, 6 deletions
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index 34813798b2..a91df323ce 100644
--- a/compiler/ghci/Linker.hs
+++ b/compiler/ghci/Linker.hs
@@ -1547,15 +1547,22 @@ getSystemDirectories = return []
-- given. If the variable does not exist then just return the identity.
addEnvPaths :: String -> [String] -> IO [String]
addEnvPaths name list
- = do values <- lookupEnv name
+ = do -- According to POSIX (chapter 8.3) a zero-length prefix means current
+ -- working directory. Replace empty strings in the env variable with
+ -- `working_dir` (see also #14695).
+ working_dir <- getCurrentDirectory
+ values <- lookupEnv name
case values of
Nothing -> return list
- Just arr -> return $ list ++ splitEnv arr
+ Just arr -> return $ list ++ splitEnv working_dir arr
where
- splitEnv :: String -> [String]
- splitEnv value = case break (== envListSep) value of
- (x, [] ) -> [x]
- (x, (_:xs)) -> x : splitEnv xs
+ splitEnv :: FilePath -> String -> [String]
+ splitEnv working_dir value =
+ case break (== envListSep) value of
+ (x, [] ) ->
+ [if null x then working_dir else x]
+ (x, (_:xs)) ->
+ (if null x then working_dir else x) : splitEnv working_dir xs
#if defined(mingw32_HOST_OS)
envListSep = ';'
#else
diff --git a/testsuite/tests/rts/Makefile b/testsuite/tests/rts/Makefile
index a6d248201b..ded3be1b3b 100644
--- a/testsuite/tests/rts/Makefile
+++ b/testsuite/tests/rts/Makefile
@@ -174,3 +174,7 @@ T11788:
.PHONY: T12497
T12497:
echo main | "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS_INTERACTIVE)) T12497.hs
+
+.PHONY: T14695
+T14695:
+ echo ":quit" | LD_LIBRARY_PATH="foo:" "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS_INTERACTIVE))
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index 6377bde04f..fe86dd1146 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -382,3 +382,4 @@ test('T12903', [when(opsys('mingw32'), skip)], compile_and_run, [''])
test('T13832', exit_code(1), compile_and_run, ['-threaded'])
test('T13894', normal, compile_and_run, [''])
test('T14497', normal, compile_and_run, ['-O'])
+test('T14695', normal, run_command, ['$MAKE -s --no-print-directory T14695'])