gpt4 book ai didi

npm - 为什么这个 fish while 循环在单次迭代后终止?

转载 作者:行者123 更新时间:2023-12-01 12:06:46 25 4
gpt4 key购买 nike

这是一个用于为项目升级 JavaScript 包的 fish 函数。奇怪的是,它在单次迭代后终止,退出状态为 0。为什么?

function yarn-upgrade-all --description "Upgrade JavaScript packages"
yarn outdated | sed '1,/^Package/d;/^Done/d' | awk '{print $1, $4}' | while read -l PACKAGE VERSION
echo
set_color brwhite
echo -n "==>"
set_color yellow
echo -n " "$PACKAGE
set_color brblue
echo -n " "$VERSION
set_color brwhite
echo -n " <=="
set_color normal
echo
echo

yarn upgrade --latest $PACKAGE
and yarn run test
and yarn run build
and git commit -am "Upgrade to "$PACKAGE" "$VERSION
or begin
set_color red
echo "last command exited with status $status" >&2
set_color normal
return 1
end
end
end

另一方面,第二个函数只包含一个 stub 体,遍历通过管道进入循环的所有包。

function yarn-upgrade-all-debug --description "Upgrade JavaScript packages"
yarn outdated | sed '1,/^Package/d;/^Done/d' | awk '{print $1, $4}' | while read -l PACKAGE VERSION
echo $PACKAGE $VERSION
end
end

fish --version

fish,版本 3.0.2

最佳答案

您正在运行 fish 3.0.0,并点击了 https://github.com/fish-shell/fish-shell/issues/5513 - returnwhile 实际上并没有正确设置状态。

但是,return 仍然会导致它终止 while 循环。

升级到 3.0.2。

关于npm - 为什么这个 fish while 循环在单次迭代后终止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55751619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com