【问题标题】:`git bisect run` with a bash function带有 bash 功能的“git bisect run”
【发布时间】:2021-06-14 05:12:34
【问题描述】:

有没有一种方便的方法来编写一个 bash 脚本来运行git bisect run,其中使用的 bisect 命令本身就是一个 bash 函数?如果我的函数名为step,则git bisect run stepgit bisect run bash -c step 似乎都无法看到该函数。

我的脚本目前看起来像

function step {
  # Do a bunch of steps here
}

if [[ $_ == $0 ]]  # Test if the script is being sourced
then
  git bisect start
  git bisect bad bad-commit
  git bisect good good-commit
  git bisect run bash -c ". $0 && step"
  git bisect log
fi

这使用了一种粗略的技巧,即在传递给git bisect run 的命令中生成脚本本身,这意味着在尝试执行git bisect 命令之前,我必须检查脚本当前是否正在获取。

我想我可以将 bash 函数拆分为一个单独的脚本,但是有更好的方法可以在一个文件中完成这一切吗?

【问题讨论】:

标签: bash git git-bisect


【解决方案1】:

您可以使用export -f step 导出函数,也可以使用set -a 导出脚本中的所有内容。

【讨论】:

  • 这就是我最终做的,我想。谢谢!
猜你喜欢
  • 1970-01-01
  • 2015-07-07
  • 2015-09-15
  • 2013-11-17
  • 2020-07-26
  • 1970-01-01
  • 2020-10-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多