huge longrun improvements

This commit is contained in:
fatalerrors
2026-03-06 17:46:26 +01:00
parent 39a7e7b40f
commit 2ece711e1a
17 changed files with 1233 additions and 481 deletions

View File

@@ -36,38 +36,53 @@
# ------------------------------------------------------------------------------
# Look for a package within installed one
# ------------------------------------------------------------------------------
# Usage: dpkgs <string>
pkgs()
{
local count=0
for opt in $@; do
case $opt in
"-h" | "--help")
echo "dpkgs: look for an installed package by it's name."
echo
echo "Usage: dpkgs <string>"
return 0
;;
local ignore_case=0
"-"*)
disp E "Invalid option, use \"dpkgs --help\" to display usage."
echo
return 1
;;
local PARSED
PARSED=$(getopt -o hi --long help,ignore-case -n 'pkgs' -- "$@")
if [[ $? -ne 0 ]]; then
disp E "Invalid options, use \"pkgs --help\" to display usage."
return 1
fi
eval set -- "$PARSED"
*)
local pkg=$1 && shift
count=$(($count + 1))
[[ $count -gt 1 ]] &&
disp E "Please specify a package name, without space, eventually partial." &&
while true; do
case "$1" in
-h|--help)
printf "pkgs: Look for an installed package by its name.\n\n"
printf "Usage: pkgs [options] <string>\n\n"
printf "Options:\n"
printf "\t-h, --help\tDisplay this help screen\n"
printf "\t-i, --ignore-case\tIgnore case distinctions\n"
return 0
;;
-i|--ignore-case)
ignore_case=1
shift
;;
--)
shift
break
;;
*)
disp E "Invalid option: $1"
return 1
;;
;;
esac
done
[[ $count -lt 1 ]] &&
disp E "Please specify a package name, without space, eventually partial." &&
local pkg="$1"
[[ -z "$pkg" ]] && {
disp E "Please specify a package name, without space, eventually partial."
return 1
}
# Build grep command
local grep_opt=""
(( ignore_case )) && grep_opt="-i"
command -v dpkg >/dev/null 2>&1 && local cmd="dpkg -l"
command -v rpm >/dev/null 2>&1 && local cmd="rpm -qa"
@@ -75,9 +90,10 @@ pkgs()
disp E "No usable package manager seems unavialable."
return 2
fi
$cmd | grep $pkg
$cmd | grep $grep_opt $pkg
}
export -f pkgs
# ------------------------------------------------------------------------------
# EOF