我想运行一个由几个“片段”组成的命令。
php="php"
options="-l"
for f in `git diff-index --cached --name-only HEAD | grep -e '\(php\|phtml\)$'`; do
if [ -f $f ]; then
# Here I want to run my command defined
# in $php and $options and put the result in
# $php_lint var
# like this command would do:
# php_lint=$(php -l $f)
# but with something like that:
# php_lint=eval $php $options $f
fi
done
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
更新:
在某个特定点上挣扎之后,我问了这个问题:
请看一下,它也可以帮助您。