zsh-workers
 help / color / mirror / code / Atom feed
* f() { ...; } > file
@ 2008-11-05 21:20 Stephane Chazelas
  2008-11-05 22:49 ` Phil Pennock
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Stephane Chazelas @ 2008-11-05 21:20 UTC (permalink / raw)
  To: Zsh hackers list

Hiya,

$ bash -c 'foo() { echo a >&3; } 3>&1; foo'
a
$ ksh -c 'foo() { echo a >&3; } 3>&1; foo'
a
$ zsh -c 'foo() { echo a >&3; } 3>&1; foo'
foo: 3: bad file descriptor
$ ARGV0=sh zsh -c 'foo() { command echo a >&3; } 3>&1; foo'
foo: 3: bad file descriptor

It looks like zsh evaluates the redirection at the time the
function is defined rather than when it is called.

It's OK when declaring the function as

foo() echo a > file
or
foo() (echo a) > file

instead of

foo() { echo a; } > file

-- 
Stéphane


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

end of thread, other threads:[~2008-11-13 15:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-05 21:20 f() { ...; } > file Stephane Chazelas
2008-11-05 22:49 ` Phil Pennock
2008-11-06 14:38   ` Stephane Chazelas
2008-11-13 14:25 ` Stephane Chazelas
2008-11-13 14:42 ` [PATCH] " Stephane Chazelas
2008-11-13 14:52   ` Peter Stephenson
2008-11-13 15:03     ` Stephane Chazelas
2008-11-13 15:13       ` Stephane Chazelas
2008-11-13 15:27         ` Peter Stephenson
2008-11-13 14:55   ` Stephane Chazelas

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).