Article 57NK2 Shell script, what does this line do: "cat -- << EOF >${CreateScript_DeployDirs}"

Shell script, what does this line do: "cat -- << EOF >${CreateScript_DeployDirs}"

by
nkamp
from LinuxQuestions.org on (#57NK2)
Hello,

I'm analyzing a script from someone else and I'm asking what does this line do?

In short I have made a test script, trying to understand how it works..., but it is not clear to me:
Code:set -euo pipefail
LocalPath="/home"
TempPath="nkamp/$(date +%Y-%m-%d)"

function DeployReleaseKit() {

local CreateScript_DeployDirs=${LocalPath}/${TempPath}/linux/deploy
local BackupScript_Previous="BackupScript_dir"

#Deploy the releasekit
echo "1. Start function start deploy Releasekit"

cat -- << EOF >${CreateScript_DeployDirs}
#!/bin/bash
echo -n
echo "2. indien getoond is de local variabel ${CreateScript_DeployDirs} een waarde"
exit 0
EOF

cat -- << EOF >${BackupScript_Previous}

echo -n
echo " 3. indien dit getoond wordt heeft de variabele ${BackupScript_Previous} een waarde!"
EOF

echo "Dit is het eind van de functie - DeployReleaseKit -"

}

echo "Roep de functie DeployReleaseKit aan" # var: CreateScript_DeployDirs: kan niet = local - BackupScript_Previous: ${BackupScript_Previous}"
DeployReleaseKit
echo "De functie deployReleaseKit is aangeroepen" # var: CreateScript_DeployDirs: kan niet = local - BackupScript_Previous: ${BackupScript_Previous} "

exit 0
~My expectations is that, if the variable {CreateScript_DeployDirs} has a value than the part till the first EOF is not executed. If it does not have a value than the part is till EOF is executed. Or just the other way around.

But this is the result:
Quote:
[nkamp@192 ~]$ ./test.sh
Roep de functie DeployReleaseKit aan
1. Start function start deploy Releasekit
./test.sh: line 14: /home/nkamp/2020-09-02/linux/deploy: Is a directory

[nkamp@192 ~]$ ./test.sh
Roep de functie DeployReleaseKit aan
1. Start function start deploy Releasekit
./test.sh: line 14: //linux/deploy: No such file or directory
This was not what I expected. (first result: the vars. ${LocalPath} and ${TempPath} does have a right value. Second result not)

I hope that someone can explain how this work and why and/or when such a construction should be used.

Nico.latest?d=yIl2AUoC8zA latest?i=zvkiilYSTdk:GDaiCpDYP-8:F7zBnMy latest?i=zvkiilYSTdk:GDaiCpDYP-8:V_sGLiP latest?d=qj6IDK7rITs latest?i=zvkiilYSTdk:GDaiCpDYP-8:gIN9vFwzvkiilYSTdk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments