Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: (feature request) Shell script within shell script
- X-seq: zsh-users 5862
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: (feature request) Shell script within shell script
- Date: Mon, 03 Feb 2003 10:31:00 +0000
- In-reply-to: ""Bart Schaefer""'s message of "Sat, 01 Feb 2003 19:29:38 GMT." <1030201192938.ZM7570@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
"Bart Schaefer" wrote:
> The tricky bit of course is that the redirection becomes the standard
> input of the "herefile" function, so your script will see end-of-file
> as soon as it starts running.
Of course you don't necessarily need to use a here-document at all.
therefile() {
setopt localtraps localoptions noshwordsplit
local tmp=${TMPPREFIX}HERE$$
trap "command rm -f $tmp" EXIT
touch $tmp || return
chmod u=rwx,go-rwx $tmp || return
print -r "$1" >>$tmp || return
shift
$tmp "$@"
}
therefile \
'#!/usr/local/bin/perl
print "You typed: @ARGV\n";
' arg1 arg2
You typed: arg1 arg2
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author