Skip to content

Add more debug info#607

Merged
JiepengTan merged 1 commit intogoplus:devfrom
JiepengTan:pr_add_more_debug_info
Apr 23, 2025
Merged

Add more debug info#607
JiepengTan merged 1 commit intogoplus:devfrom
JiepengTan:pr_add_more_debug_info

Conversation

@JiepengTan
Copy link
Copy Markdown
Contributor

No description provided.

@JiepengTan JiepengTan requested a review from nighca April 23, 2025 07:46
Comment thread cmd/gox/setup_font.sh
@@ -0,0 +1,99 @@
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd $SCRIPT_DIR
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. [SC2164]

Details

lint 解释

这个lint结果表明在脚本中使用了cd ...命令,但没有处理可能的失败情况。如果cd命令执行失败,脚本将继续执行后续的命令,这可能会导致意外的行为。

错误用法

cd /path/to/directory
# 如果 cd 失败,脚本会继续执行
echo "Directory changed"

正确用法

cd /path/to/directory || exit 1
# 或者
cd /path/to/directory || return 1
# 如果 cd 失败,脚本会退出或返回错误码
echo "Directory changed"

💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

Comment thread cmd/gox/setup_font.sh
if [ -n "$font_path" ]; then

cp "$font_path" "$target_font_path"
if [ $? -ne 0 ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. [SC2181]

Details

lint 解释

这个lint结果提示你在检查命令的退出状态时,应该直接使用if ! mycmd;这样的形式,而不是通过间接地检查$?变量。这样可以更清晰和准确地判断命令是否成功执行。

错误用法

mycmd
if [ $? -ne 0 ]; then
    echo "Command failed"
fi

在这个错误的示例中,我们首先运行了mycmd命令,然后通过检查$?变量来判断命令是否成功执行。虽然这种方法在大多数情况下是有效的,但lint工具建议直接使用if ! mycmd;的形式。

正确用法

if ! mycmd; then
    echo "Command failed"
fi

在这个正确的示例中,我们直接使用了if ! mycmd;的形式来检查命令的退出状态。这种方式更加简洁和直观,符合lint工具的建议。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

@JiepengTan JiepengTan force-pushed the pr_add_more_debug_info branch from 84d6aff to 26ea72a Compare April 23, 2025 08:48
@JiepengTan JiepengTan merged commit c7dfef6 into goplus:dev Apr 23, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants