以下の内容はhttps://tbpgr.hatenablog.com/entry/20140528/1401281114より取得しました。


Ruby | CLI | Play Well with Others | Accessing Exit Codes of Other Commands

概要

書籍 Build Awesome Command-Line Applications in Ruby2

Play Well with Others

詳細

$? という名前はBashをやっている人には慣れ親しんだ変数名だが
その他人にはわかりにくい。
より人間に読みやすくするため、標準ライブラリの English を利用します。

サンプル

require 'English'

# 成功時
system('echo hoge')
puts $?.exitstatus
puts $CHILD_STATUS.exitstatus

# 失敗時
system('invalid_command')
puts $?.exitstatus
puts $CHILD_STATUS.exitstatus

出力

hoge
0
0
127
127



以上の内容はhttps://tbpgr.hatenablog.com/entry/20140528/1401281114より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14