从Rake文件执行的bash命令 [英] Execute bash commands from a Rakefile

查看:385
本文介绍了从Rake文件执行的bash命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行一个号庆典中从 Rake文件命令。我主动壳庆典,我会打电话庆典

I would like to execute a number of bash commands from a Rakefile. My active shell is bash and I will be calling rake from bash.

我已经包含在我的 Rake文件以下

task :hello do
  %{echo "World!"}
end

但在执行耙你好没有输出?

我如何从一个Rake文件执行的bash命令?

How do I execute bash commands from a Rakefile?

注意:这不是一个重复,因为它是专门询问如何执行的bash命令从一个的 Rake文件

NOTE:This is not a duplicate as it's specifically asking how to execute bash commands from a Rakefile.

推荐答案

我觉得耙的方式要做到这一点是:<一href=\"http://rubydoc.info/gems/rake/FileUtils#sh-instance_method\">http://rubydoc.info/gems/rake/FileUtils#sh-instance_method
例如:

I think the way rake wants this to happen is with: http://rubydoc.info/gems/rake/FileUtils#sh-instance_method Example:

task :test do
  sh "ls"
end

内置耙功能SH接收命令的返回值的关心和此外它​​还输出命令的输出(如果命令比0的返回值的任务失败)。

The built-in rake function sh takes care of the return value of the command (the task fails if the command has a return value other than 0) and in addition it also outputs the commands output.

这篇关于从Rake文件执行的bash命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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