bug-bash
[Top][All Lists]
Advanced

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

Re: redirection / process substitution fails to read a file descriptor


From: Chet Ramey
Subject: Re: redirection / process substitution fails to read a file descriptor
Date: Mon, 18 Nov 2024 16:04:51 -0500
User-agent: Mozilla Thunderbird

On 11/17/24 6:25 PM, Robert Elz wrote:

The use for testing for errors is also occasionally useful - a redirection
error will cause the shell to exit (non-interactive shell) so <file can
be a kind of shortcut for
        test -r file || { printf >&2 message; exit 2; }
(or similar) (and output directions test that the file either exists or
can be created, and is writeable).

No, it usually doesn't. If a redirection error occurs with a special
builtin, POSIX says a non-interactive shell should exit. However,
just running

< file

where file doesn't exist or isn't readable, won't cause a non-interactive
shell to exit.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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