I basically want to write me a bash script where I would generate a couple of large files using heredoc ; and then run some commands using these files.
Itโs clear that (obviously) heredoc files must be generated before executing the commands, however, which annoys me in this layout, I must also write the โheredocโ instruction code before writing the command code.
So, it seemed to me that I would write heredoc instructions in functions, but still the same problem: Chapter 24. Functions says:
A function definition must precede the first call. There is no method for "declaring" a function, for example, in C.
Indeed, this is so:
$ cat > test.sh <<EOF testo function testo { echo "a" } EOF $ bash test.sh test.sh: line 1: testo: command not found
Then I thought that maybe I could place some tags and jump using GOTO , as in (pseudocode):
$ cat > test.sh <<EOF goto :FUNCLABEL :MAIN testo goto :EXIT :FUNCLABEL function testo { echo "a" } goto MAIN :EXIT
... but it turns out BASH goto also does not exist.
My only goal is to first write the "core" of a script file, which consists of several commands from five to six; and only then write the heredoc statements in the script file (which may contain hundreds of lines); with heredocs at first really makes reading code difficult for me. Is there any way to achieve this?
sdaau
source share