这在 bash 中应该很简单,我不知道我为什么要为此苦苦挣扎。我是 bash 新手,所以请温柔一点。
伪代码:
read a configuration file, extract the first line beginning with a key/value pair
in the format exec=/path/to/myprog -opt1 -opt2 $var1 $var2 ...
check that the /path/to/myprog is executable
if executable then
replace $var1, ... with the contents of the same bash variables in the script
check that all variables were replaced with existing bash variables
if aok
execute the command and be happy
else
complain echoing the partially-substituted command string
fi
else
complain echoing the un-substituted command string
fi
我尝试的任何方法似乎都无法正常工作。我已经消磨了足够的时间尝试各种事情。建议,有人吗?