kev*_*kev 10 bash environment-variables
我尝试将变量导出回父进程。
$ export VAR=FALSE
$ echo $VAR
FALSE
$ ./myprogram # this will set VAR=TRUE
$ echo $VAR
TRUE <========== I want to print `TRUE` here
Run Code Online (Sandbox Code Playgroud)
Ign*_*ams 11
做不到。将任何内容传递给父进程的唯一可靠方法是回显它并让父进程使用命令替换来捕获它。
VAR=$(./myprogram)
Run Code Online (Sandbox Code Playgroud)
小智 5
实际上......我刚刚使用它来工作source
如果myprogram
包含:
export VAR=TRUE
Run Code Online (Sandbox Code Playgroud)
然后运行后source myprogram
你的案例就会起作用。
归档时间: |
|
查看次数: |
5997 次 |
最近记录: |