Skip to main content

Thread: Bash: Why are these two variables treated differently?


i'm reading value text file environment variable, this;

code:
export current_q=( $(< "current_q.txt") )
now, if echo this, looks right. but, there's separate process i'm kicking off (an internal application) tries use variable, , fails.

however, if this;

code:
tmp_current_q=( $(< "current_q.txt") ) export current_q=$tmp_current_q
it works.

have when variable expression parsed? - i.e. in second example, current_q contains 'real' value of variable. in first example, file hasn't been read yet?

confused here.

you can't export array variables. i'm not sure how bash handles export var=( ), it's pointless anyway, don't it. trying do?

reading content of file variable or array, do
code:
var=$(<"$filename")         # entire content stored 1 long string mapfile -t arr <"$filename" # content stored in array named arr, 1 line per element.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Bash: Why are these two variables treated differently?


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support