fix(build): eliminate the error message when no extension found in a folder in building

In the building when there is not any extensions with given pattern exist, 'enable_extensions_with_hostdeps_builtin_and_user()' will throw errors such as: 'Error 123 occurred in SUBSHELL SUBSHELL at /<some-path>/lib/functions/general/extensions.sh:582'. The changes will eliminate the error message and add prints to show the current searched folder and extensions count found in the folder.

Signed-off-by: diverger <diverger@live.cn>
This commit is contained in:
diverger
2025-09-21 23:20:57 +08:00
committed by Igor
parent 859b49c32f
commit fc3cc6b6e3

View File

@@ -577,10 +577,14 @@ function enable_extensions_with_hostdeps_builtin_and_user() {
# Extensions are files of the format <dir>/extension_name.sh or <dir>/extension_name/extension_name.sh # Extensions are files of the format <dir>/extension_name.sh or <dir>/extension_name/extension_name.sh
for ext_dir in "${ext_dirs[@]}"; do for ext_dir in "${ext_dirs[@]}"; do
display_alert "Extension search" "Searching in directory: \"${ext_dir}\"" ""
if [[ -d "${ext_dir}" ]]; then if [[ -d "${ext_dir}" ]]; then
declare -a ext_list_dir=() declare -a ext_list_dir=()
mapfile -t ext_list_dir < <(find "${ext_dir}" -maxdepth 2 -type f -name "*.sh" -print0 | xargs -0 grep -l "${grep_args[@]}") mapfile -t ext_list_dir < <(find "${ext_dir}" -maxdepth 2 -type f -name "*.sh" -print0 | xargs -0 -r grep -l "${grep_args[@]}" 2>/dev/null || true)
display_alert "Extension search result" "Found ${#ext_list_dir[@]} extensions in \"${ext_dir}\"" ""
extension_list+=("${ext_list_dir[@]}") extension_list+=("${ext_list_dir[@]}")
else
display_alert "Extension search" "Directory does not exist: \"${ext_dir}\"" "wrn"
fi fi
done done