【发布时间】:2017-06-14 07:50:03
【问题描述】:
只有当pgrep -x foo 的输出为空时,我才尝试激活一些 Lua 行。我尝试了以下方法:
if os.execute("pgrep -x foo") then
-- My lines here
end
但是,这似乎不是正确的解决方案,即使在语法上也可以。
【问题讨论】:
标签: bash shell lua command conditional
只有当pgrep -x foo 的输出为空时,我才尝试激活一些 Lua 行。我尝试了以下方法:
if os.execute("pgrep -x foo") then
-- My lines here
end
但是,这似乎不是正确的解决方案,即使在语法上也可以。
【问题讨论】:
标签: bash shell lua command conditional
也许尝试检查nil:
if os.execute('pgrep -x foo') == nil then
print('empty')
end
如果您不希望匹配“精确”,则删除 -x 选项。
【讨论】: