Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: (feature request) Shell script within shell script
- X-seq: zsh-users 5897
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: (feature request) Shell script within shell script
- Date: Sat, 8 Feb 2003 02:31:26 +0000
- In-reply-to: <20030207202324.GA31158@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20030128042243.GA3888@xxxxxxxxxxxxxxxxxxxxxx> <20030128104034.GA6470@xxxxxxxxxxxxxxxxxxxxxx> <20030131204945.GA1189@xxxxxxxxxxxxxxxxxxxxxx> <20030201073655.GA3893@xxxxxxxxxxxxxxxxxxxxxx> <20030203231518.GA8900@xxxxxxxxxxxxxxxxxxxxxx> <1030204091832.ZM15610@xxxxxxxxxxxxxxxxxxxxxxx> <20030207202324.GA31158@xxxxxxxxxxxxxxxxxxxxxx>
On Feb 7, 3:23pm, William Park wrote:
}
} A classic solution:
}
} function test1 () {
} exec 10<<"EOF"
} ...
} ...
} EOF
} awk -f /dev/fd/10
} exec 10<&-
} }
}
} I didn't have to patch anything. I just have to keep track of fd's
} instead of external files.
Did you actually try that? It certainly doesn't work for me. You
can't use two-or-more-digit numbers to represent FDs for redirection:
zagzig% cat 10<<EOF
heredoc> foo bar
heredoc> EOF
cat: 10: No such file or directory
It works if you change 10 to 9, but it's overkill. All you need is:
awk -f /dev/fd/9 9<<\EOF
...
...
EOF
And if you happen to encounter a command that requires a real seekable
file for its input, you can do this:
awk -f =(<&9) 9<<\EOF
...
...
EOF
However, I'd like to point out that this is not what you originally
asked for. You asked how to create a script, complete with #! line,
and execute it, not how to feed a here-document to a command that
expects a file name.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author