MyTetra Share
Делитесь знаниями!
export
Время создания: 31.08.2017 20:51
Текстовые метки: knowledge
Раздел: bash - Variables
Запись: xintrea/mytetra_db_mcold/master/base/1500457785ziiv3lmb97/text.html на raw.githubusercontent.com

Now run:


$ MYVAR=hello
$ ./myvar2.sh
MYVAR is:
MYVAR is: hi there


$ MYVAR=hello
$
./myvar2.sh
MYVAR is
:
MYVAR is
: hi there

It's still not been set! What's going on?! 
When you call 
myvar2.sh from your interactive shell, a new shell is spawned to run the script. This is partly because of the #!/bin/sh line at the start of the script, which we discussed earlier
We need to export the variable for it to be inherited by another program - including a shell script. Type:


$ export MYVAR
$ ./myvar2.sh
MYVAR is: hello
MYVAR is: hi there

$ export MYVAR
$
./myvar2.sh
MYVAR is
: hello
MYVAR is
: hi there

Так же в этом разделе:
 
MyTetra Share v.0.65
Яндекс индекс цитирования