[英]Why does sem (GNU parallel) behave differently with single quotes and double quotes?
I can't understand the following behavior of sem
from GNU Parallel. 我无法理解来自GNU Parallel的
sem
的以下行为。 When I use single quotes, it seems to work well: 当我使用单引号时,它似乎运作良好:
sem -j1 'echo $(date);sleep 5;echo $(date)'
sem --wait
gives 给
Sat Apr 23 15:46:50 EDT 2016
Sat Apr 23 15:46:55 EDT 2016
However, when I use double quotes. 但是,当我使用双引号时。
sem -j1 "echo $(date);sleep 5;echo $(date)"
sem --wait
the result is 结果是
Sat Apr 23 15:46:08 EDT 2016
Sat Apr 23 15:46:08 EDT 2016
where it seems that the sleep 5
is totally ignored. 似乎
sleep 5
完全被忽略了。
Could anyone explain why this happens? 谁能解释为什么会这样? Is it caused by GNU parallel or bash?
它是由GNU parallel还是bash引起的?
It has nothing to do with sem
or GNU parallel, but everything to do with the shell. 它与
sem
或GNU并行无关,但与shell有关。
When you use double-quotes for strings, the shell expands all environment variable references at once . 当您使用双引号字符串,外壳马上展开所有环境变量的引用。 If you use single-quoted strings the shell doesn't do that variable expansion.
如果使用单引号字符串,则shell不会执行该变量扩展。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.