如何首先扩展字符串然后求值?

时间:2019-02-22 07:21:41

标签: bash

非常简单:如何进行这项工作:

export predicate='[[ $LINE $arg ]]'
export LINE=10
export arg='-gt 3'
eval $predicate

产生:

eval "${predicate}"
bash: conditional binary operator expected
bash: syntax error near `$arg'
bash -x -c 'eval "${predicate}"'

尝试2:

$ eval $(echo ${predicate})
bash: conditional binary operator expected
bash: syntax error near `$arg'

尝试3:

+ eval '[[ $LINE $arg ]]'
bash: eval: line 0: conditional binary operator expected
bash: eval: line 0: syntax error near `$arg'
bash: eval: line 0: `[[ $LINE $arg ]]'

根本就没有扩展这些变量。

0 个答案:

没有答案