Environment initialization pulls the prebuilt engine instead of building it from source#552
Conversation
| @@ -14,7 +18,8 @@ done | |||
| source $SCRIPT_DIR/common/setup_env.sh | |||
There was a problem hiding this comment.
note: Not following: ./common/setup_env.sh was not specified as input (see shellcheck -x). [SC1091]
Details
lint 解释
这个lint结果表明在脚本中引用了./common/setup_env.sh文件,但该文件没有被指定为输入。这可能会导致脚本无法正确地找到和执行该文件。
错误用法
source ./common/setup_env.sh正确用法
要解决这个问题,你需要确保./common/setup_env.sh文件被正确地指定为输入。具体操作取决于你使用的工具或环境。例如,如果你使用的是ShellCheck,可以这样修改:
# 确保在脚本的开头添加以下行
#!/bin/bash -e
# 指定输入文件
input_files="./common/setup_env.sh"
# 执行脚本
source $input_files或者,如果你使用的是其他工具或环境,请根据具体情况进行相应的修改。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
| @@ -14,7 +18,8 @@ done | |||
| source $SCRIPT_DIR/common/setup_env.sh | |||
| cd $PROJ_DIR | |||
There was a problem hiding this comment.
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 辅助生成,如有疑问欢迎反馈交流
| download_editor() { | ||
| setup_global_variables | ||
| local platform=$PLATFORM | ||
| local arch=$ARCH |
There was a problem hiding this comment.
note: Possible misspelling: ARCH may not be assigned. Did you mean arch? [SC2153]
Details
lint 解释
这个lint结果提示你在脚本中可能拼写错误,ARCH 可能没有被赋值。建议你检查是否想使用 arch 而不是 ARCH。
错误用法
if [ "$ARCH" == "x86_64" ]; then
echo "Building for x86_64"
fi在这个例子中,ARCH 没有被赋值,可能会导致脚本运行时出错。
正确用法
if [ "$arch" == "x86_64" ]; then
echo "Building for x86_64"
fi在这个例子中,使用了小写的 arch,确保变量名拼写正确。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
|
|
||
| if [ "$EDITOR_ONLY" = true ]; then | ||
| if [ "$platform" = "linux" ]; then | ||
| zip_name="editor-linux-"$arch".zip" |
There was a problem hiding this comment.
warning: The surrounding quotes actually unquote this. Remove or escape them. [SC2027]
Details
lint 解释
这个lint结果表明在脚本中使用了反引号(`)来执行命令,但反引号内部的字符串被错误地用双引号或单引号包围。这会导致反引号无法正确解析内部的变量或命令。
错误用法
result=`echo "Hello, $USER"`在这个例子中,$USER 被错误地用双引号包围,导致反引号无法正确解析 $USER 变量。
正确用法
result=$(echo "Hello, $USER")在这个例子中,使用了 $() 语法来执行命令,这样可以正确解析内部的变量。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
| url=$url_prefix$zip_name | ||
| curl -L -o "$tmp_dir/$zip_name" "$url" || exit | ||
| unzip -o "$tmp_dir/$zip_name" -d "$tmp_dir" > /dev/null 2>&1 || exit | ||
| rm -rf "$tmp_dir/$zip_name" |
There was a problem hiding this comment.
warning: Use "${var:?}" to ensure this never expands to / . [SC2115]
Details
lint 解释
这个lint结果表明在脚本中使用了变量,但没有确保该变量不会被空值(/)替换。${var:?} 是一种更安全的引用方式,它会在变量为空时抛出错误,而不是将其替换为默认值。
错误用法
echo "The value is $VAR"在这个例子中,如果 VAR 为空,脚本会输出 The value is /,这可能不是预期的行为。
正确用法
echo "The value is ${VAR:?}"在这个例子中,如果 VAR 为空,脚本会抛出错误,提示变量未定义或为空,而不是将其替换为默认值。这样可以避免潜在的错误和混淆。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
|
|
||
| build_editor(){ | ||
| prepare_env | ||
| cd $ENGINE_DIR |
There was a problem hiding this comment.
note: Possible misspelling: ENGINE_DIR may not be assigned. Did you mean engine_dir? [SC2153]
Details
lint 解释
这个lint结果提示你在脚本中可能拼写错误,ENGINE_DIR 可能没有被正确赋值。建议你检查是否应该使用 engine_dir 而不是 ENGINE_DIR。
错误用法
if [ -z "$ENGINE_DIR" ]; then
echo "ENGINE_DIR is not set"
fi正确用法
if [ -z "$engine_dir" ]; then
echo "engine_dir is not set"
fi💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
| if [ "$PLATFORM" == "web" ]; then | ||
| build_target "$ENGINE_DIR" "$PLATFORM" "$TEMPLATE_DIR" | ||
| exit 0 | ||
| build_template "$ENGINE_DIR" "$PLATFORM" "$TEMPLATE_DIR" |
There was a problem hiding this comment.
note: Possible misspelling: TEMPLATE_DIR may not be assigned. Did you mean template_dir? [SC2153]
Details
lint 解释
这个lint结果提示在代码中可能有一个拼写错误。具体来说,TEMPLATE_DIR 可能没有被赋值,建议检查是否应该是 template_dir。
错误用法
TEMPLATE_DIR=/path/to/template正确用法
template_dir=/path/to/template💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
| rm -rf "$tmp_dir/godot.linuxbsd.editor.$arch" | ||
|
|
||
| elif [ "$platform" = "windows" ]; then | ||
| zip_name="editor-windows-"$arch".zip" |
There was a problem hiding this comment.
warning: The surrounding quotes actually unquote this. Remove or escape them. [SC2027]
Details
lint 解释
这个lint结果表明在脚本中使用了反引号(`)来执行命令,但反引号内部的字符串被错误地用双引号或单引号包围。这会导致反引号无法正确解析内部的变量或命令。
错误用法
result=`echo "Hello, $USER"`在这个例子中,$USER 被错误地用双引号包围,导致反引号无法正确解析 $USER 变量。
正确用法
result=$(echo "Hello, $USER")在这个例子中,使用了 $() 语法来执行命令,这样可以正确解析内部的变量。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
| url=$url_prefix$zip_name | ||
| curl -L -o "$tmp_dir/$zip_name" "$url" || exit | ||
| unzip -o "$tmp_dir/$zip_name" -d "$tmp_dir" > /dev/null 2>&1 || exit | ||
| rm -rf "$tmp_dir/$zip_name" |
There was a problem hiding this comment.
warning: Use "${var:?}" to ensure this never expands to / . [SC2115]
Details
lint 解释
这个lint结果表明在脚本中使用了变量,但没有确保该变量不会被空值(/)替换。${var:?} 是一种更安全的引用方式,它会在变量为空时抛出错误,而不是将其替换为默认值。
错误用法
echo "The value is $VAR"在这个例子中,如果 VAR 为空,脚本会输出 The value is /,这可能不是预期的行为。
正确用法
echo "The value is ${VAR:?}"在这个例子中,如果 VAR 为空,脚本会抛出错误,提示变量未定义或为空,而不是将其替换为默认值。这样可以避免潜在的错误和混淆。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
8f0e8ae to
92211db
Compare
| url=$url_prefix$zip_name | ||
| curl -L -o "$tmp_dir/$zip_name" "$url" || exit | ||
| unzip -o "$tmp_dir/$zip_name" -d "$tmp_dir" > /dev/null 2>&1 || exit | ||
| rm -rf "$tmp_dir/$zip_name" |
There was a problem hiding this comment.
warning: Use "${var:?}" to ensure this never expands to / . [SC2115]
Details
lint 解释
这个lint结果表明在脚本中使用了变量,但没有确保该变量不会被空值(/)替换。${var:?} 是一种更安全的引用方式,它会在变量为空时抛出错误,而不是将其替换为默认值。
错误用法
echo "The value is $VAR"在这个例子中,如果 VAR 为空,脚本会输出 The value is /,这可能不是你想要的结果。
正确用法
echo "The value is ${VAR:?}"在这个例子中,如果 VAR 为空,脚本会抛出错误,提示变量未定义或为空。这样可以避免意外的空值替换。
💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流
92211db to
0c80558
Compare
how to use