summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2006-09-13 11:46:04 +0000
committerbringert <bringert@cs.chalmers.se>2006-09-13 11:46:04 +0000
commitf41c8fd2fc5d837d4f03976e886d918aed114cf2 (patch)
tree54aea26a8210cbbcdc82684e14cb474971310ed2
parentba950aab14782e95b41f378df4de014b38347665 (diff)
transferc now uses env var TRANSFER_PATH to locate imports.
-rw-r--r--transfer/transferc.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/transfer/transferc.hs b/transfer/transferc.hs
index a363ff75c..7a88d8e3a 100644
--- a/transfer/transferc.hs
+++ b/transfer/transferc.hs
@@ -12,14 +12,28 @@ die s = do
hPutStrLn stderr s
exitFailure
+getPath :: IO [String]
+getPath = do env <- getEnvironment
+ return $ case lookup "TRANSFER_PATH" env of
+ Nothing -> []
+ Just p -> splitBy (==':') p
+
+-- Modified version of a function which is originally
+-- Copyright Bryn Keller
+splitBy :: (a -> Bool) -> [a] -> [[a]]
+splitBy _ [] = []
+splitBy f list = first : splitBy f (dropWhile f rest)
+ where (first, rest) = break f list
+
main :: IO ()
main = do
args <- getArgs
let (flags,files) = partition ("-" `isPrefixOf`) args
- path = [ p | ('-':'i':p) <- flags ]
+ argPath = [ p | ('-':'i':p) <- flags ]
+ envPath <- getPath
case files of
[f] -> do
- cf <- compileFile path f
+ cf <- compileFile (argPath ++ envPath) f
putStrLn $ "Wrote " ++ cf
return ()
_ -> die "Usage: transferc [-i<path> [-i<path> ... ]] <file>"