Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: (feature request) Shell script within shell script



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