From: nobu.nakada@... Date: 2004-04-15T17:59:49+09:00 Subject: [ruby-dev:23385] Process::Status as boolean なかだです。 systemの戻り値は成功/失敗をシステムに依存しない形で判定できます が、Process::waitpidや``の場合、$?.exitstatusを使う必要があって EXIT_SUCCESSの値に依存してしまいます。 で、exitstatus==EXIT_SUCCESSを返す、Process::Status#success?と いうメソッドはどうでしょうか。Process::EXIT_SUCCESSなどの定数で もいいんですが、systemとの一貫性からはこっちのほうがいいと思い ます。 Index: process.c =================================================================== RCS file: /cvs/ruby/src/ruby/process.c,v retrieving revision 1.102 diff -u -2 -p -r1.102 process.c --- process.c 14 Apr 2004 04:06:25 -0000 1.102 +++ process.c 15 Apr 2004 08:57:17 -0000 @@ -512,5 +512,25 @@ pst_wexitstatus(st) /* * call-seq: - * stat.coredump => true or false + * stat.success? => true, false or nil + * + * Returns +true+ if _stat_ is successful, +false+ if not. + * Returns +nil+ if exited? is not +true+. + */ + +static VALUE +pst_success_p(st) + VALUE st; +{ + int status = NUM2INT(st); + + if (!WIFEXITED(status)) + return Qnil; + return WEXITSTATUS(status) == EXIT_SUCCESS ? Qtrue : Qfalse; +} + + +/* + * call-seq: + * stat.coredump? => true or false * * Returns +true+ if _stat_ generated a coredump -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦