Re: How to make a bourne shell user-defined function take input from heredoc
On 25 Aug 2006 03:40:49 -0700, Rakesh Sharma wrote:
> hi,
>
> how do we make a user-defined function in bourne shells to be able to
> take it's input(s) from either it's argument list or a heredoc?
>
> For example,
>
> func1() {
> printf '%s\n' "$@"
> return 0
> }
>
> func1 "$var1" 'arg2' # works fine when arguments provided
> # by means of shell variables or hardcoded strings
>
> # but this doesnt work
> func1 << EOF
> this is some heredoc
> usage: FOOBAR tmpdir tmpfile codename
> EOF
[...]
func1() {
if [ "$#" -eq 0 ]; then
cat
else
printf '%s\n' "$@"
fi
return 0
}
--
Stephane
|