Platform independent null device access

What do people think about adding a method to class IO that returns an IO
object for the platform dependend null device (NUL on win, /dev/null or
/dev/zero on unix)? Alternatively there could be a constant with the
platform dependent name of this device, if it can always be opened like a
file on all supported platforms.

Regards

robert

/dev/null is great when the program doesn’t have it’s own way to discard
data, but in this case, it might be easier and more cross-platform to
simply have an IO object who’s read and write do nothing.

···

On Thu, 2003-05-08 at 10:52, Robert Klemme wrote:

What do people think about adding a method to class IO that returns an IO
object for the platform dependend null device (NUL on win, /dev/null or
/dev/zero on unix)? Alternatively there could be a constant with the
platform dependent name of this device, if it can always be opened like a
file on all supported platforms.

Regards

robert


Tom Felker

Rather a geek than a sheep.

Saluton!

NUL on win,

AFAIK Windows has /dev/null but things may be different with the
obsolete 9x series.

Gis,

Josef ‘Jupp’ Schugt

···


e-mails that do not contain plain text, are larger than 50 KiB, are
unsolicited, or contain binarys are ignored unless payment from your
side or technical reasons give rise to a non-standard treatment.

Hi,

NUL on win,

AFAIK Windows has /dev/null but things may be different with the
obsolete 9x series.

Really? Don’t you mean cygwin?

Anyway, what about this?

def File.null
open(“/dev/null”, “r+”)
rescue Errno::ENOENT
open(“nul”, “r+”)
end

···

At Fri, 9 May 2003 07:22:44 +0900, Josef ‘Jupp’ Schugt wrote:


Nobu Nakada

“Tom Felker” tcfelker@mtco.com schrieb im Newsbeitrag
news:1052427342.2330.61.camel@tom.felker.net

What do people think about adding a method to class IO that returns an
IO
object for the platform dependend null device (NUL on win, /dev/null
or
/dev/zero on unix)? Alternatively there could be a constant with the
platform dependent name of this device, if it can always be opened
like a
file on all supported platforms.

/dev/null is great when the program doesn’t have it’s own way to discard
data, but in this case, it might be easier and more cross-platform to
simply have an IO object who’s read and write do nothing.

This does not work with child processes that are no ruby processes.

robert
···

On Thu, 2003-05-08 at 10:52, Robert Klemme wrote:

“Josef ‘Jupp’ Schugt” jupp@gmx.de schrieb im Newsbeitrag
news:20030508201502.GE3255@jupp%gmx.de

Saluton!

NUL on win,

AFAIK Windows has /dev/null but things may be different with the
obsolete 9x series.

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\temp>echo g
g

C:\temp>echo g > /dev/null
Das System kann den angegebenen Pfad nicht finden.

C:\temp>echo g > NUL

C:\temp>

robert