如何通过/ bin / time处理引用的args


1

我正在计算表单中的自定义二进制文件: ./prog --opt1=arg1 --opt2=arg2 --opt3="arg3"

要求第三个选项具有引用参数。在脚本中,我保存了所有选项:

exec=./prog
opts="--opt1=arg1 --opt2=arg2 --opt3=\"arg3\""

当我尝试计算程序时,我的程序解析args时出错了。我猜它是因为它看到最后一个arg没有被引用。输出/bin/time

\bin\time -v $exec $opts

Error parsing args (来自我的节目)
Command being timed: "./prog --opt1=arg1 --opt2=arg2 --opt3="arg3""

但是,当我只是复制和粘贴时,它声称命令是什么,它运行良好:

./prog --opt1=arg1 --opt2=arg2 --opt3="arg3" - 很好

是什么/bin/time做什么,我怎么能解决这个问题?我猜它与引号有关,比如它可能运行eval或者其他东西。我不知道该怎么办。

Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.