General TC > Programming & Scripting - Unofficial
[Solved] variable expansion inside a here-file issue
patrikg:
I can't get this of my head, just remembers that linux use two variables settings.
First you have the shell variables, which is not transferred between parent to child.
And you have something called environment variables. that stays between parent to child.
So if you want the variable to stay between parent to child you need to export it.
If i don't misunderstand your problem it seems to maybe be that the shell spawn's another shell and don't inherit the variable between parent to child.
So maybe when you assign your variable within your shell, just add the command export in front of it like this:
--- Code: (bash) ---export N="Test"
--- End code ---
--- Code: (bash) ---not like this:
N="Test"
--- End code ---
Lets play with this like this.
--- Code: (bash) ---> TEST="Test"
> echo $TEST
Test
> bash
> echo $TEST
> exit
exit
> echo $TEST
Test
> export TEST
> bash
> echo $TEST
Test
> exit
exit
> export TEST1="Test2"
> bash
> echo $TEST1
Test2
> exit
exit
--- End code ---
jazzbiker:
Hi patrikg,
You are quite right about exported variables. But if we are discussing the issue that broke aus9's script it crawls from another grim door named "here-files" or maybe "here-documents". Are You acquainted with this topic?
GNUser:
--- Quote from: jazzbiker on July 17, 2023, 07:52:33 AM ---the issue that broke aus9's script...crawls from another grim door...
--- End quote ---
Hi, Andrey. Thanks for making me laugh ;D
What I like best about GNU/Linux is that there are no "Keep Out" signs anywhere. Other OSes seem not to have grim doors and crawling things--but that's only because the user is not allowed to look around.
patrikg:
--- Quote from: jazzbiker on July 17, 2023, 07:52:33 AM ---Hi patrikg,
You are quite right about exported variables. But if we are discussing the issue that broke aus9's script it crawls from another grim door named "here-files" or maybe "here-documents". Are You acquainted with this topic?
--- End quote ---
Yes I am familer with this type of word and there meaning.
Okey I get it, I think.
Like the good movie Inception, nested/recursion things like dream in a dream, and what that is being supported with heredoc or herefile.
GNUser:
I would try 1000 other approaches before considering a nested here document. I don't like pain.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version