-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix install-release.sh by shellcheck #92
Conversation
@@ -254,7 +254,7 @@ get_version() { | |||
TMP_FILE="$(mktemp)" | |||
install_software curl | |||
# DO NOT QUOTE THESE `${PROXY}` VARIABLES! | |||
if ! "curl" ${PROXY} -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then | |||
if ! "curl" "${PROXY}" -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO NOT QUOTE THESE ${PROXY}
VARIABLES!
留意注释。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看过这个变量赋值,
因为你用的赋值是没有空格的,(-xsocks5=xxxxx)
所以这里用quote 是没问题的,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是这样的,我过去套用 shellcheck 的 autofix 给这里加了双引号,造成实际传递 proxy 参数给脚本时,跑到这里会出错。
@@ -520,7 +516,7 @@ main() { | |||
# Parameter information | |||
[[ "$HELP" -eq '1' ]] && show_help | |||
[[ "$CHECK" -eq '1' ]] && check_update | |||
[[ "$REMOVE" -eq '1' ]] && remove_v2ray | |||
[[ "$REMOVE" -eq '1' ]] && remove_v2ray "$REMOVE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove_v2ray 函数不需要任何参数。我不明白为什么你会在这里做这一更改。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是因为shellcheck会作为一个严重问题警告,
要么就去掉函数里的参数引用,
此处加上是为了忽略警告,(最小无害改动)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们写这个脚本不是为了通过 shellcheck 的警告,你不用把作为参考的建议当成必须解决的问题。
你提到说去掉函数里的参数引用,我现在在手机上不方便看,你把你说的 remove_v2ray 函数里有问题的地方引用出来给我看看呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无他,shellcheck 给出的建议非常好而已,
给养成良好的习惯,就最大减少错误。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在我看来这里的解决方案是从 remove_v2ray 函数里移除对 NAME 的赋值。
这个变量只在 install_file 函数里用到,而这个函数自己已经实现了对这个变量必要的赋值。
总的来说这个 PR 简化了很多逻辑,把原来用到其他系统命令的地方整合进 awk 的技巧我也很欣赏。 从优化脚本的角度来说,我觉得有个 shellcheck 看不出来,但其实比较值得关注的问题是现在脚本对传入参数的实现。 如果你真的有心优化这个安装脚本,我会比较建议你从上面这个问题入手(我因为开学了所以最近没时间做这种体力活,工程有点繁大), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
见上面的讨论。
这个其实比较简单,一个while就可以搞定了。 |
这个 PR 里包含已经在 #108 里提交的修改。 |
No description provided.