我有一个CLI工具,需要以以下方式调用:
foobar run -- [command]
例如
foobar run -- script.sh
问题是,我想在同一个shell脚本中安装CLI工具。我如何使用下面的结构做到这一点呢?
# My script I want to run with the CLI tool
perform_actions () {
# ...
}
# Installing CLI tool from some URL
# ...
# Execute my script with the CLI tool
foobar run -- perform_actions # This doesn't work because perform_actions is a function发布于 2021-03-13 20:13:45
我会这样组织脚本:
#!/usr/bin/env bash
SCRIPT_SH=$(cd $(dirname $BASH_SOURCE);pwd)/$(basename $BASH_SOURCE)
# My script I want to run with the CLI tool
perform_actions () {
# ...
}
foobar_run(){
foobar run -- $SCRIPT_SH perform_actions
}
# Installing CLI tool from some URL
# ...
# Execute my script with the CLI tool
# foobar run -- perform_actions # This doesn't work because perform_actions is a function
"$@"要运行该脚本:
./script.sh foobar_runhttps://stackoverflow.com/questions/66613006
复制相似问题