【发布时间】:2014-09-17 11:05:46
【问题描述】:
当我编写一个简单的脚本并将其传递给 runhaskell 时,它工作正常,但当我添加一个 shebang 并尝试直接执行它时就不行了。脚本是这样的:
#!/usr/local/bin/runhaskell
import Data.List (intercalate)
main :: IO ()
main = putStrLn $ intercalate " " $ map show [1..10]
如果我尝试$ runhaskell count.hs bash 按预期打印1 2 3 4 5 6 7 8 9 10,但如果我尝试./count.hs 我会收到以下错误:
./count.hs: line 3: syntax error near unexpected token `('
./count.hs: line 3: `import Data.List (intercalate)'
这个错误是源自 bash 还是 runhaskell?我该如何解决?
【问题讨论】:
-
这是
runhaskell的正确路径吗?因为那看起来确实像一个 shell 错误。 runhaskell 本身是带有shebang的脚本吗?这是什么系统/操作系统?
标签: bash shell haskell scripting