[Feature:trunk] IO::NULL; null device path name

e$B$J$+$@$G$9!#e(B

IO::NULL e$B$rDI2C$9$k$N$O$I$&$G$7$g$&$+!#e(B

diff --git a/io.c b/io.c
index 05b2d45…3793ae5 100644
— a/io.c
+++ b/io.c
@@ -9623,6 +9623,18 @@ rb_get_argv(void)
return ARGF.argv;
}

+static const char null_device[] =
+#if defined DOSISH

  • “NUL”
    +#elif defined AMIGA || defined amigaos
  • “NIL”
    +#elif defined __VMS
  • “NL:”
    +#else
  • “/dev/null”
    +#endif
  • ;

/*

  • Document-class: IOError

@@ -9956,6 +9968,8 @@ Init_IO(void)
rb_define_method(rb_cIO, “autoclose?”, rb_io_autoclose_p, 0);
rb_define_method(rb_cIO, “autoclose=”, rb_io_set_autoclose, 1);

  • rb_define_const(rb_cIO, “NULL”,
    rb_obj_freeze(rb_usascii_str_new2(null_device)));
  • rb_define_variable("$stdin", &rb_stdin);
    rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO, “”);
    rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);

e$B%A%1%C%He(B #3526 e$B$,99?7$5$l$^$7$?!#e(B (by Run Paint Run R.)

No objection, FWIW. Looks to mirror Python’s os.devnull. AFAICT, NUL
does not necessarily exist on a Windows system, but that can’t be
helped. Issue 1311: os.path.exists(os.devnull) regression on windows - Python tracker suggests there may be problems
stat’ing NUL on Windows–affecting #exists? and #stat, possibly–but
I’m not in a position to verify.

http://redmine.ruby-lang.org/issues/show/3526

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:41791] [Feature:trunk] IO::NULL; null device path
name”
on Jul.03,2010 11:08:26, [email protected] wrote:

IO::NULL e$B$rDI2C$9$k$N$O$I$&$G$7$g$&$+!#e(B

IOe$B$@$H!"$J$s$H$J$/!"e(BIOe$B%*%V%8%'%/%H$,JV$C$F$/$k$3$H$r4|BT$7$Fe(B
e$B$7$^$&5$$,$7$^$9!#e(B

e$B$G!"e(BNULLe$B%G%P%$%9$,M_$7$$?M$K$O%U%!%$%kL>$,M_$7$$?M$b$$$l$Pe(BIO
e$B%*%V%8%'%/%H$,M_$7$$?M$b$$$k$G$7$g$&$+$i!“MQ0U$9$k$H$7$?$iA0e(B
e$B<T$G$”$m$&$H$$$&E@$OF10U$G$-$^$9!#e(B

e$B$H$$$&$o$1$G!"e(BFile::NULLe$B$G$I$&$G$7$g$&$+e(B?

e$B$=$l$G$O!#e(B

e$B%A%1%C%He(B #3526 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

This issue was solved with changeset r29110.
Nobuyoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


http://redmine.ruby-lang.org/issues/show/3526