From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: PATCH: functions with redirections
Date: Wed, 01 Oct 2014 21:07:41 -0700 [thread overview]
Message-ID: <141001210741.ZM6790@torch.brasslantern.com> (raw)
In-Reply-To: <20141001201705.23ee198d@pws-pc.ntlworld.com>
On Oct 1, 8:17pm, Peter Stephenson wrote:
} Subject: Re: PATCH: functions with redirections
}
} On Mon, 29 Sep 2014 14:37:35 -0700
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} >
} > foo () { echo foo } >&3
} >
} > becomes
} >
} > foo () { { echo foo } >&3 }
}
} This appears to be about the only way I could even conceivably get this
} to work --- otherwise it means reengineering multiple different ways of
} constructing and reading a dump file --- but even this appears too
} difficult.
It's also apparently wrong, if this ...
} +function is executed. Any variables in the redirection are expanded
} +at the point the function is executed, but outside the function scope.
... is actually the way it's supposed to work.
} The main sticking point is where you need to add the wrapper
} you have an Eprog, and it's hard to convert that back into the form you
} need for adding additional components or glueing bits together ---
Yes. This was what I ran into as well.
} So I'll simply document around this and be satisfied with the fact that
} it is possible to compile an autoload file like
}
} foo() { echo foo } >&3
}
} with or without the zsh kludge 'foo "$@"' stuck at the end. I suspect
} compiling existing autoload files is much more common than compiling
} functions typed into the shell.
Hmm.
torch% cat /tmp/foo
foo() { echo foo } >&3
torch% zcompile -k /tmp/foo
torch% autoload foo
torch% FPATH=/tmp foo
foo
Oops, the redirection didn't get applied. But it does once the function
is loaded and then called:
torch% functions foo
foo () {
echo foo
} >&3
torch% foo
zsh: 3: bad file descriptor
torch%
next prev parent reply other threads:[~2014-10-02 4:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-29 19:52 Peter Stephenson
2014-09-29 20:27 ` Peter Stephenson
2014-09-29 20:53 ` Bart Schaefer
2014-09-29 21:37 ` Bart Schaefer
2014-09-30 4:51 ` Mikael Magnusson
2014-10-01 19:17 ` Peter Stephenson
2014-10-02 4:07 ` Bart Schaefer [this message]
2014-10-02 8:35 ` Peter Stephenson
2014-10-02 14:55 ` Peter Stephenson
2014-10-02 15:54 ` Bart Schaefer
2014-10-02 15:56 ` Bart Schaefer
2014-10-02 16:03 ` Peter Stephenson
2014-09-30 1:02 ` Bart Schaefer
2014-09-30 8:48 ` Peter Stephenson
2014-09-30 11:52 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=141001210741.ZM6790@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).