I want to pass a segment of a script to a subshell, so I export it as a function. When I was trying this, I happened to notice I cannot export a function containing a nested function that ends with heredoc.
For example:
#!/bin/bash
f() {
g() {
cat <<EOF
EOF
}
g
}
export -f f
bash -c ':'
If I run it, the subshell fails and prints:
bash: f: line 8: syntax error: unexpected end of file
bash: error importing function definition for `f'
What's wrong with my script?