[+] tot-safe: Count packages only when command succeed

Fixes #145
This commit is contained in:
Azalea 2023-06-30 01:58:52 -07:00
parent 2ce7a59a59
commit 176f08ad0b

View file

@ -1933,6 +1933,14 @@ get_packages() {
((packages+=${#pkgs[@]})); ((packages+=${#pkgs[@]}));
pac "$((${#pkgs[@]}-pkgs_h))"; pac "$((${#pkgs[@]}-pkgs_h))";
} }
# Similar with tot but do nothing if the command fails
tot-safe() {
if pkgs="$("$@")"; then
pkgs=$(echo "$pkgs" | wc -l)
((packages+=pkgs))
pac "$((pkgs-pkgs_h))";
fi
}
# Redefine tot() and dir() for Bedrock Linux. # Redefine tot() and dir() for Bedrock Linux.
[[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]] && { [[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]] && {
@ -1981,7 +1989,7 @@ get_packages() {
has pisi && tot pisi li has pisi && tot pisi li
has pacstall && tot pacstall -L has pacstall && tot pacstall -L
has bulge && tot bulge list has bulge && tot bulge list
has pm && tot pm list packages has pm && tot-safe pm list packages
has evox && tot cat /var/evox/packages/DB has evox && tot cat /var/evox/packages/DB
has tea && tot find "$HOME/.tea" -maxdepth 2 -mindepth 2 -type d has tea && tot find "$HOME/.tea" -maxdepth 2 -mindepth 2 -type d