bugfix, esthetic cleanup, better comments, version bump

This commit is contained in:
Geoffray Levasseur-Brandin
2024-06-21 16:19:44 +02:00
parent 9e49e3e4d7
commit bef205ae84
18 changed files with 634 additions and 571 deletions

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details.
@@ -36,32 +37,32 @@
# ------------------------------------------------------------------------------
# Look for a package within installed one
# ------------------------------------------------------------------------------
pkgs ()
pkgs()
{
local count=0
for opt in $@ ; do
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
;;
"-h" | "--help")
echo "dpkgs: look for an installed package by it's name."
echo
echo "Usage: dpkgs <string>"
return 0
;;
"-"*)
disp E "Invalid option, use \"dpkgs --help\" to display usage."
echo
"-"*)
disp E "Invalid option, use \"dpkgs --help\" to display usage."
echo
return 1
;;
*)
local pkg=$1 && shift
count=$(($count + 1))
[[ $count -gt 1 ]] &&
disp E "Please specify a package name, without space, eventually partial." &&
return 1
;;
*)
local pkg=$1 && shift
count=$(( $count + 1 ))
[[ $count -gt 1 ]] &&
disp E "Please specify a package name, without space, eventually partial." &&
return 1
;;
;;
esac
done
[[ $count -lt 1 ]] &&
@@ -71,9 +72,12 @@ pkgs ()
command -v dpkg >/dev/null 2>&1 && local cmd="dpkg -l"
command -v rpm >/dev/null 2>&1 && local cmd="rpm -qa"
if [[ -z $cmd ]]; then
disp E "No usable package manager seems unavialable."
return 2
disp E "No usable package manager seems unavialable."
return 2
fi
$cmd | grep $pkg
}
export -f pkgs
# ------------------------------------------------------------------------------
# EOF