Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: detect pipe



On Sat, Jan 30, 2021 at 6:27 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Cool stuff Bart.  Would you please elaborate on 'Close stdin'?

ubuntu% ls /dev/fd/0
/dev/fd/0
ubuntu% ls /dev/fd/0 <&-
ls: cannot access '/dev/fd/0': No such file or directory

File descriptor zero, the standard input, has been closed; it
literally does not exist for "ls" (in this example).  If it's closed,
it's not possible to read from it:

ubuntu% cat <&-
cat: -: Bad file descriptor
cat: closing standard input: Bad file descriptor

Most commands will ignore a closed stdin and behave similarly to
reading from /dev/null.




Messages sorted by: Reverse Date, Date, Thread, Author