zsh-workers
 help / color / mirror / code / Atom feed
* process substitution bug?
@ 2005-03-16 20:43 Alexey Tourbin
  2005-03-17  5:35 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Tourbin @ 2005-03-16 20:43 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 348 bytes --]

Hi,

When I wrap some command into a function, process substitution
no longer works:

$ =diff <(echo 1) <(echo 2)
1c1
< 1
---
> 2
$ diff () {
function> =diff "$@"
function> }
$ diff <(echo 1) <(echo 2)
/usr/bin/diff: /proc/self/fd/11: No such file or directory
/usr/bin/diff: /proc/self/fd/12: No such file or directory
$ echo $ZSH_VERSION
4.2.4
$

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: process substitution bug?
  2005-03-16 20:43 process substitution bug? Alexey Tourbin
@ 2005-03-17  5:35 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2005-03-17  5:35 UTC (permalink / raw)
  To: zsh-workers

On Mar 16, 11:43pm, Alexey Tourbin wrote:
}
} When I wrap some command into a function, process substitution
} no longer works:

This is not precisely a bug, it's a limitation of process substitution
and the shell file descriptor management model.

} $ =diff <(echo 1) <(echo 2)

In this case there's a single external command being run; the file
descriptors opened for the process substitutions remain open across
fork(), so diff can reference them via /proc/self/fd/.

} $ diff <(echo 1) <(echo 2)
} /usr/bin/diff: /proc/self/fd/11: No such file or directory
} /usr/bin/diff: /proc/self/fd/12: No such file or directory

Here, the diff function is being executed in the current shell.  The
file descriptors are opened for the shell function and all the shell
builtin commands, but (because they have numbers > 9) they are closed
when external commands are executed within the function.

Replace "diff" with a builtin such as "stat" (zmodload zsh/stat) and
you'll see that the process substitution is working.

It could be argued that descriptors opened by process substitution
should remain open across external command execution within functions;
they do, in e.g. bash.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-17  5:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-16 20:43 process substitution bug? Alexey Tourbin
2005-03-17  5:35 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).