General TC > Programming & Scripting - Unofficial

[Solved] variable expansion inside a here-file issue

<< < (3/5) > >>

Paul_123:
Variable expansion happens as the script is written too.  Can be really tricky

Why do you need to write the script from a script?  Can you just include the script as a file?

aus9:
Thanks Paul_123
I am glad others are seeing some issue too.

Lets drop this. I can upload it as a file -> in my build script use wget to get it and include it the submission under src/

Hi jazzbiker
I try to have as much text stuff inside my build script. But I give up on this one.
The build script includes a help file, well more of a howto as I will be leaving it to the victim oops I mean the member to maintain their get-script  ;D
and thanks for your feedback

Hi Rich
Please mark as solved and at your discretion change subject to something like
variable expansion inside a here-file issue or anything you think might better describe what happened.


patrikg:
You could also test to use some another variable substitution, with the curly brackets.
Like this. or do you need the dollar sign variable in the script you make, you need to escape that character because of the variable substitution.


--- Code: (bash) ---cat > ${N} << EOF

--- End code ---


--- Code: (bash) ---cat > \${N} << EOF

--- End code ---

or like your way.


--- Code: (bash) ---cat > \$N << EOF

--- End code ---

Rich:
Hi aus9

--- Quote from: aus9 on July 16, 2023, 09:16:47 AM --- ... Please mark as solved and at your discretion change subject to something like
variable expansion inside a here-file issue ...
--- End quote ---
Done.

jazzbiker:

--- Quote from: patrikg on July 16, 2023, 09:21:46 AM ---You could also test to use some another variable substitution, with the curly brackets.
Like this. or do you need the dollar sign variable in the script you make, you need to escape that character because of the variable substitution.


--- Code: (bash) ---cat > ${N} << EOF

--- End code ---


--- Code: (bash) ---cat > \${N} << EOF

--- End code ---

or like your way.


--- Code: (bash) ---cat > \$N << EOF

--- End code ---

--- End quote ---

Hi patrikg,

Sorry but not

--- Code: ---tc@box:~$ cat aaa
cat > bbb << EOF2
N=abc
cat > ${N} << EOF
ls
EOF
EOF2
tc@box:~$ . ./aaa
tc@box:~$ cat bbb
N=abc
cat >  << EOF
ls
EOF

--- End code ---

The issue aus9 faced is related to the variables expansion as Paul_123 noted. This is not syntax error. Don't sit to play dice with the devil. Simply don't do it )

Have a nice Core!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version