[Top][All Lists]

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

Re: trap handler scope wrong?

From: Chet Ramey
Subject: Re: trap handler scope wrong?
Date: Sun, 05 Mar 2006 21:32:43 -0500
User-agent: Thunderbird 1.5 (Macintosh/20051201)

Phillip Susi wrote:
> Chet Ramey wrote:
>>> trap "cat $LOG > &3" ERR
>>> {
>>>  foo
>>>  bar
>>> } 3>&1 > /dev/null
>> That's about right, but you need >&3 in the trap command.
> I did have > &3 in the trap command, see?

There can't be a space between `>' and `&'.  That's a syntax error.

> I'm a bit worried though about hard coding the fd 3.  Is there a way to
> get the next available fd number and save it in a variable, rather than
> hard code 3?

Why worry about it?  The script writer is entitled to use any file
descriptor between 0 and 9.  If bash is using it internally, it will
switch to another.

``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
                                           Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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