如何从haskell程序调用bash或shell脚本? [英] How to invoke bash or shell scripts from a haskell program?

查看:117
本文介绍了如何从haskell程序调用bash或shell脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用haskell编写一些shell脚本,我正在gitbash中运行它,但是我想从这些脚本中使用其他一些现有脚本.

I'm writing some shell scripts with haskell, which I'm running in gitbash, but there are a few other existing scripts I'd like to be able to use from those scripts.

例如,我想运行Maven目标或进行git pull,但不必专门与这些工具集成.

For example, I'd like to run maven goals or do a git pull, but without having to integrate specifically with those tools.

有没有办法做到这一点?

Is there a way to do this?

推荐答案

您可以使用

You can use System.Process. For example, executing seq 1 10 shell command:

> import System.Process

> readProcess "seq" ["1", "10"] ""
"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"
it :: String

> readProcessWithExitCode  "seq" ["1", "10"] ""
(ExitSuccess,"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n","")
it :: (GHC.IO.Exception.ExitCode, String, String)

这篇关于如何从haskell程序调用bash或shell脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆