从功能中调用源

发布于 2025-02-03 07:58:12 字数 831 浏览 3 评论 0 原文

我目前正在从ZSH移到鱼。我的大多数别名等都很容易移植,但是我遇到以下问题的问题:

alias idf.py='unalias idf.py; source $IDF_PATH/export.sh; idf.py'

我知道在鱼类别名中只是句法糖的功能,所以我开始编写以下功能:

function "idf.py"
  source $IDF_PATH/export.fish
  functions --erase idf.py
  idf.py $argv
end

export.fish fish脚本来自 esp-idf ,并开始抱怨需要采购。之后,该功能被正确删除了,但是找不到IDF.PY:

his script should be sourced, not executed:
realpath: /home/robert/Programs/esp-idf/export.fish/..: Not a directory
.
fish: Unknown command: idf.py
fish: 
  idf.py $argv
  ^
in function 'idf.py'

您是否知道如何从此功能内部源到全局范围?

I'm currently moving from zsh to fish. Most of my aliases etc are pretty easy to port, but I'm running into problems with the following one:

alias idf.py='unalias idf.py; source $IDF_PATH/export.sh; idf.py'

I know in fish aliases are just syntactic sugar for functions so I started writing the following function:

function "idf.py"
  source $IDF_PATH/export.fish
  functions --erase idf.py
  idf.py $argv
end

the export.fish script is from the esp-idf and starts complaining about needing to be sourced. After that the function gets removed correctly but idf.py can not be found:

his script should be sourced, not executed:
realpath: /home/robert/Programs/esp-idf/export.fish/..: Not a directory
.
fish: Unknown command: idf.py
fish: 
  idf.py $argv
  ^
in function 'idf.py'

Do you have any idea how I can source to the global scope from within this function?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光与爱终年不遇 2025-02-10 07:58:12

刚刚进行您链接到的项目的提交历史记录 - 您链接的ESP-IDF脚本是最新版本,但是您收到的错误是来自早期版本此后已修复了该脚本的版本。

该脚本试图通过测试状态当前命令来检测是否使用 source 命令调用它,但是由于您是从函数 idf中调用它的。 py 返回的名称,而不是 source

这是一个错误,大约在两年前仅通过删除源检查就解决了。

升级到最新的ESP-IDF版本应处理它。

Just going on the commit history of the project you linked to -- The ESP-IDF script you linked is the latest version, but the error you are receiving was from a bug in an earlier version of the script that has since been fixed.

The script attempts to detect whether it is being called with the source command by testing status current-command, but since you are calling it from within the function idf.py, that's the name returned, rather than source.

It was a bug, and it was fixed about two years ago by simply removing the source check.

Upgrading to the latest ESP-IDF release should take care of it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文