How do I proc out with tilde expansion AND $PATH searching in Haskell?

traffichazard

I'm trying to run the elm-reactor project, which is written in Haskell. It fails because it's trying to proc out to the elm command like this:

createProcess (proc "elm" $ args fileName)

My elm executable is sitting in ~/.cabal/bin, which is in my PATH.

The System.Process.proc command searches the $PATH for its command argument, but it doesn't do tilde (~) expansion, so it doesn't find elm.

System.Process.shell has the opposite problem. It does tilde expansion, but it doesn't search the $PATH, apparently.

From the source of the System.Process command, it looks like most everything rests on a foreign ccall to "runInteractiveProcess", which I assume is doing whatever $PATH searching is being done. I don't know where the source for runInteractiveProcess would be, and my C is about 15 years worth of rusty.

I can work around this issue by

a) adding the fully-expanded cabal/bin path to my PATH or

b) symlinking an elm from the working directory to its location in cabal/bin.

However, I'd like to offer a suggested fix to the elm project, to save future adopters the trouble I've gone through. Is there a System.Process call that they should be making here that I haven't tried? Or is there a different method they should be using? I suppose at worst they could getEnv for the PATH and HOME, and implement their own file search using that before calling proc - but that breaks cross-platform compatibility. Any other suggestions?

ErikR

Try using shell instead of proc, i.e.:

createProcess (shell "elm")

This should invoke elm via a shell, which hopefully will interpret tildes in $PATH as desired.

Update: Here is the experiment I performed to test what shell does...

  1. Compile the following program (I called it run-foofoo):

    import System.Process

    main = do (,,_,h) <- createProcess $ shell "foofoo" ec <- waitForProcess h print ec

  2. Create a new directory ~/new-bin and place the following perl script there as the file foofoo:

    #!/usr/bin/perl

    print "Got here and PATH is $ENV{PATH}\n";

  3. Run: chmod a+rx ~/new-bin/foofoo

Test with:

PATH="/bin:/usr/bin:/sbin" ./run-foofoo                  # should fail
PATH="$HOME/new-bin:/bin:/usr/bin:/sbin" ./run-foofoo    # should succeed
PATH="~/new-bin:/bin:/usr/bin:/sbin" ./run-foofoo        # ???

On my OSX system, the third test reports:

Got here and PATH is ~/new-bin:/bin:/usr/bin:/sbin
ExitSuccess

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

合并Kinvey中的用户

来自分类Dev

PostgreSQL:有效地将JSON数组拆分为行

来自分类Dev

是否可以在UITextField中设置较大的空间

来自分类Dev

从git bisect错误中恢复更有针对性吗?

来自分类Dev

GIT SVN:在没有错误的合并父级的情况下获取重新创建的SVN分支

来自分类Dev

如何在核心数据模型iOS中找出特定属性索引的值

来自分类Dev

iOS-Xcode中的iPad预览丢失

来自分类Dev

Java:方法挂钩和查找对象实例

来自分类Dev

使用git diff,如何显示从索引到给定提交的补丁?

来自分类Dev

仅用于向上投射

来自分类Dev

如何将光标下的值乘以重复计数?

来自分类Dev

boost :: ublas如何获取int矩阵的行列式?

来自分类Dev

通过使用javascript原型系统创建共享结构的不可变对象是否有意义?

来自分类Dev

在另一个任务之前异步运行grunt任务

来自分类Dev

Bootstrap 3:滚动条

来自分类Dev

引导程序3:同一行上有两种形式

来自分类Dev

在编译时查找基类

来自分类Dev

RegionMonitoring监视的“区域”数,基于用户在iOS7中的当前位置

来自分类Dev

从一个ViewController传递到另一个ViewController的NSCache UIImage数据

来自分类Dev

Unable to find library in eclipse for Android

来自分类Dev

boost :: spirit :: qi匹配[]麻烦

来自分类Dev

可访问性不一致:与方法“ y”相比,参数类型“ x”的访问性较差

来自分类Dev

boost :: chrono :: system_clock-如何格式化当前时间到字符串?

来自分类Dev

考虑工厂功能和序列化的对象键入的推荐方法

来自分类Dev

Javascript中类似Haskell的类型签名有任何约定吗

来自分类Dev

如何使用JavaScript中的共享,不可变引用类型跟踪更改

来自分类Dev

使用Object.prototype.toString时有哪些极端情况?

来自分类Dev

索引中有缺口的数组是否带来了弥补其缺点的任何好处

来自分类Dev

如何实现更通用的reduce功能以允许提前退出?

Related 相关文章

  1. 1

    合并Kinvey中的用户

  2. 2

    PostgreSQL:有效地将JSON数组拆分为行

  3. 3

    是否可以在UITextField中设置较大的空间

  4. 4

    从git bisect错误中恢复更有针对性吗?

  5. 5

    GIT SVN:在没有错误的合并父级的情况下获取重新创建的SVN分支

  6. 6

    如何在核心数据模型iOS中找出特定属性索引的值

  7. 7

    iOS-Xcode中的iPad预览丢失

  8. 8

    Java:方法挂钩和查找对象实例

  9. 9

    使用git diff,如何显示从索引到给定提交的补丁?

  10. 10

    仅用于向上投射

  11. 11

    如何将光标下的值乘以重复计数?

  12. 12

    boost :: ublas如何获取int矩阵的行列式?

  13. 13

    通过使用javascript原型系统创建共享结构的不可变对象是否有意义?

  14. 14

    在另一个任务之前异步运行grunt任务

  15. 15

    Bootstrap 3:滚动条

  16. 16

    引导程序3:同一行上有两种形式

  17. 17

    在编译时查找基类

  18. 18

    RegionMonitoring监视的“区域”数,基于用户在iOS7中的当前位置

  19. 19

    从一个ViewController传递到另一个ViewController的NSCache UIImage数据

  20. 20

    Unable to find library in eclipse for Android

  21. 21

    boost :: spirit :: qi匹配[]麻烦

  22. 22

    可访问性不一致:与方法“ y”相比,参数类型“ x”的访问性较差

  23. 23

    boost :: chrono :: system_clock-如何格式化当前时间到字符串?

  24. 24

    考虑工厂功能和序列化的对象键入的推荐方法

  25. 25

    Javascript中类似Haskell的类型签名有任何约定吗

  26. 26

    如何使用JavaScript中的共享,不可变引用类型跟踪更改

  27. 27

    使用Object.prototype.toString时有哪些极端情况?

  28. 28

    索引中有缺口的数组是否带来了弥补其缺点的任何好处

  29. 29

    如何实现更通用的reduce功能以允许提前退出?

热门标签

归档