[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I thought >&- and > /dev/null were almost the same

From: Chet Ramey
Subject: Re: I thought >&- and > /dev/null were almost the same
Date: Mon, 26 Nov 2001 09:34:57 -0500

> $ date > /dev/null
> $ date >&-
> date: write error: Bad file descriptor

These are not the same thing.  The first provides `date' a valid file
descriptor 0 that is opened on /dev/null.  The second closes file descriptor 0.

> $ echo o >&-

Echo doesn't check the validity of its output file descriptor; it just
tries to write.  The return status indicates any errors.

$ echo o >&-
$ echo $?


``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]