如何测试 karaf 控制台脚本中是否安装了某个功能?

How to test if a feature is installed in a karaf console script?

我需要编写一个 karaf 控制台脚本来卸载某个功能,如果它存在于 karaf 3.0.4 上。

到目前为止,我还没有在文档中找到任何直接引用 mentionend (https://karaf.apache.org/manual/latest-3.0.x/developers-guide/scripting.html)。始终使用 shell:env ? returns null 作为值,我不确定 ? 是否是 karaf 中受支持的环境变量名称。

那么,如果存在某个功能,如何执行 karaf 命令?

无法测试 3.0.4 版的 karaf 控制台脚本中是否安装了某个功能。这是因为 commands for scope feature do not return anything to the console (see the source code).

解决方法是 deploy another command 将 returns 布尔值传递给控制台并在脚本中使用它。