Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: allocating a new file descriptor
- X-seq: zsh-workers 21140
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: Re: PATCH: allocating a new file descriptor
- Date: Thu, 14 Apr 2005 14:23:37 +0000
- In-reply-to: <200504140949.j3E9n5Kp006216@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <200504121257.j3CCvkXr003286@xxxxxxxxxxxxxx> <1050414045748.ZM13551@xxxxxxxxxxxxxxxxxxxxxxx> <200504140949.j3E9n5Kp006216@xxxxxxxxxxxxxx>
On Apr 14, 10:49am, Peter Stephenson wrote:
} Subject: Re: PATCH: allocating a new file descriptor
}
} I can add documentation to point this out if you think it would be
} useful.
Possibly so.
} It would also be possible to make NO_CLOBBER check that in {myfd}>stuff,
} $myfd doesn't already point to an fd with an FDT_EXTERNAL flag. That
} would prevent overwriting. I quite like that idea.
I do, too.
} For more complicated cases you might need to set myfd to 0 first
Or (more appropriately, I would think) unset it, no?
(Given discipline functions, one could even arrange that myfd closes
its descriptor upon unset.)
} Fortuitously,
}
} print This is a log file {myfd}>~/tmp/logfile.txt >&$myfd
}
} works; $myfd is substituted at the right point. That's quite lucky,
} since most expansions have been done by this point.
At first I thought that was a little odd, but I guess really it's OK,
because this ...
print ${myfd::=2} $myfd
... also prints "2 2".
It might be useful to add a note somewhere (the "Expansion" section?)
about the ordering of parameter expansion relative to redirections.
} However, there's also the point that if you use this after an external
} command the shell has already forked and the fd doesn't appear in the
} parent shell.
That's a very interesting point. This works:
/bin/echo foo {myfd}>>(tr a-z A-Z) >&$myfd
But this causes the shell to hang forever:
print foo {myfd}>>(tr a-z A-Z) >&$myfd
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author