help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] catching read error conditions


From: Greg Wooledge
Subject: Re: [Help-bash] catching read error conditions
Date: Mon, 28 Jan 2013 08:32:02 -0500
User-agent: Mutt/1.4.2.3i

On Sat, Jan 26, 2013 at 11:34:12PM +0100, Mart Frauenlob wrote:
> 1. Detect if read times out.

The manual says:

           -t timeout
                Cause read to time out and return failure if a complete line
                of input is not read within timeout seconds.

> This is the only way I found that seems to 
> work ( || ... after the read command). Is this correct?

Well, any of the ways of testing the exit status should suffice.
Also note that you can't distinguish a failure-due-to-timeout from
other kinds of failures.

> 2. Detect if the command inside the redirected process substitution 
> fails and print a message to stderr.

A process substitution runs a command in the background, but this
command is not considered a "job" and can't be managed in the ways
that directly spawned background jobs (using "&") can be managed.

If you need to observe/control a background job directly, create your
own named pipe and launch the background job in the conventional way,
rather than using the <() or >() shortcuts.



reply via email to

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