echo 'export abc=123' | source /dev/stdin 为何无法设置变量?
Tue Aug 1 21:37:38 CST 2017补充:
https://superuser.com/questions/705204/ ... 207#705207
[已解决]echo 'export abc=123' | source /dev/stdin 为何无法设置变量?
-
- 帖子: 2284
- 注册时间: 2013-05-26 6:58
- 系统: Debian 9
- 九天星
- 帖子: 1440
- 注册时间: 2007-07-14 20:45
-
- 帖子: 2284
- 注册时间: 2013-05-26 6:58
- 系统: Debian 9
Re: echo 'export abc=123' | source /dev/stdin 为何无法设置变量?
不是您理解的这样九天星 写了:因为这是一个字符串
代码: 全选
$ help source
source: source filename [arguments]
Execute commands from a file in the current shell.
Read and execute commands from FILENAME in the current shell. The
entries in $PATH are used to find the directory containing FILENAME.
If any ARGUMENTS are supplied, they become the positional parameters
when FILENAME is executed.
Exit Status:
Returns the status of the last command executed in FILENAME; fails if
FILENAME cannot be read.
本意是想把echo的输入重定向给source去执行,但管线(Pipiline)会再开一个新的shell去执行source
"Process Substitution"(<(list))的结果是list的标准输出文件
例如:
代码: 全选
$ echo <(date)
/dev/fd/63
- 九天星
- 帖子: 1440
- 注册时间: 2007-07-14 20:45
-
- 帖子: 2284
- 注册时间: 2013-05-26 6:58
- 系统: Debian 9