本文介绍了当编写一个脚本哈斯克尔,附近获得意外的标记语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我写一个简单的脚本,并通过它来runhaskell,它工作正常,但不是当我添加家当,并尝试直接执行它。脚本是这样的:

When I write a simple script and pass it to runhaskell, it works fine, but not when I add a shebang and try executing it directly. The script is this:

#!/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 我收到以下错误:

If I try $ runhaskell count.hs bash prints 1 2 3 4 5 6 7 8 9 10 as expected, but if I try ./count.hs I get the following error:

./count.hs: line 3: syntax error near unexpected token `('
./count.hs: line 3: `import Data.List (intercalate)'

时对原产于bash或runhaskell这个错误?如何解决呢?

Is this error originating in bash or runhaskell? And how do I fix it?

推荐答案

请尝试使用:

#!/usr/bin/env runhaskell
...

请注意:这与OSX功能/问题,即家当间preters都要求是二进制文件。见Shebang指向脚本(也有家当)被有效地忽略了解更多详情。

Note: this is a feature/issue with OSX where shebang interpreters are required to be binaries. See Shebang pointing to script (also having shebang) is effectively ignored for more details.

这篇关于当编写一个脚本哈斯克尔,附近获得意外的标记语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 12:05