Skip to content

Commit

Permalink
scripts(build-package.sh): use grep directly instead of `cat | grep…
Browse files Browse the repository at this point in the history
…` for checking built packages and quote variables for all related functions
  • Loading branch information
agnostic-apollo committed Dec 21, 2024
1 parent dde75ba commit 56992fc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,23 @@ fi

# Check if the package is in the compiled list
termux_check_package_in_built_packages_list() {
[ ! -f "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH" ] && termux_error_exit "ERROR: file '$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH' not found."
cat "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH" | grep -q " $1 "
[ ! -f "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH" ] && \
termux_error_exit "ERROR: file '$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH' not found."
grep -q " $1 " "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH"
return $?
}

# Adds a package to the list of built packages if it is not in the list
termux_add_package_to_built_packages_list() {
if ! termux_check_package_in_built_packages_list "$1"; then
echo -n "$1 " >> $TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH
echo -n "$1 " >> "$TERMUX_BUILD_PACKAGE_CALL_BUILT_PACKAGES_LIST_FILE_PATH"
fi
}

# Check if the package is in the compiling list
termux_check_package_in_building_packages_list() {
[ ! -f "$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH" ] && termux_error_exit "ERROR: file '$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH' not found."
[ ! -f "$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH" ] && \
termux_error_exit "ERROR: file '$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH' not found."
grep -q "^${1}$" "$TERMUX_BUILD_PACKAGE_CALL_BUILDING_PACKAGES_LIST_FILE_PATH"
return $?
}
Expand Down

0 comments on commit 56992fc

Please sign in to comment.