1

在安装了 IncrediBuild 的构建机器上运行了一些 bash 脚本。IncrediBuild 的想法是利用网络中所有可用的内核来加速构建过程。

示例外壳脚本:

...
ib_console cmake --build .

不得更改 shell 脚本。我想在没有 ib_console 的机器上运行脚本。是否有可能以某种方式模拟它或将呼叫转发给 cmake ?

4

2 回答 2

3

将其放入您的.bashrc文件中:

if [ ! -f ´whereis ib_console´ ] then
    alias ib_console='$@'
fi

解释:

  • -f 检查 ib_console 二进制文件是否存在
  • $@将所有参数放入一个字符串(然后独立执行)
于 2018-03-21T19:58:26.710 回答
2

@alex:别名在 shell 中起作用,但在上面的 shell 脚本中不起作用,因为在非交互式 shell 脚本中没有扩展别名。

为什么我的 Bash 脚本不能识别别名?我可以修复它。

if ! [ -f 'whereis ib_console' ]; then
    ib_console()
    {
        echo "ib_console dummy: run '$@'..."
        $@
        echo "ib_console dummy: done"
    }
    export -f ib_console
fi

建议在更新 .bashrc 后运行 'exec bash'

于 2018-03-22T10:09:34.157 回答