Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > rakeライブラリ > FileUtilsモジュール > sh
sh(*cmd) {|result, status| ... }[permalink][rdoc] [added by rake]
与えられたコマンドを実行します。
与えられた引数が複数の場合、シェルを経由しないでコマンドを実行します。
例:
sh %{ls -ltr}
sh 'ls', 'file with spaces'
# check exit status after command runs
sh %{grep pattern file} do |ok, res|
if ! ok
puts "pattern not found (status = #{res.exitstatus})"
end
end
[SEE_ALSO] Kernel.#exec, Kernel.#system