How will the shell expand an include in a here-doc?
2
votes
3
answers
1400
views
I have a case of twisted shell logic to submit to you, since I have found nothing on that particular point anywhere (please accept my apologies if I missed it).
I'll try to explain the context as best I can.
I have a first
scriptA
which I expect to generate a second scriptB
through the use of a heredoc. There are two items I want to have in this heredoc: a my_source
file include, and some variables local to scriptA
(for expansion within scriptA
, that is). Here is an example:
scriptA:
#!/bin/sh
logfile=/path/to/my_logfile
scriptB=/path/to/my_script
cat > ${scriptB} parameter expansion, command substitution, and arithmetic expansion
The .
is a shell special built-in utility, which is not expanded (just like all shell built-ins, including bash-, ksh-, tcsh-specific (...) built-ins).
Thanks @ilkkachu for the insight.
Asked by Meeshkah
(23 rep)
Mar 30, 2017, 09:30 AM
Last activity: Jun 25, 2023, 02:51 PM
Last activity: Jun 25, 2023, 02:51 PM