[pahis] fixed bash completion bug for package names; removing long single-hyphen options in favor of double-hyphen counterparts

This commit is contained in:
manuel
2024-08-25 18:16:56 +03:00
parent d34a89a93c
commit 8a5d638136
3 changed files with 35 additions and 45 deletions
+3 -3
View File
@@ -4,7 +4,7 @@ pkgname=pahis
pkgdesc="Show history of package operations of one or all packages."
url=https://github.com/endeavouros-team/PKGBUILDS/tree/master/$pkgname
_url="https://raw.githubusercontent.com/endeavouros-team/PKGBUILDS/master/$pkgname"
pkgver=0.3.4
pkgver=24
pkgrel=1
arch=('any')
@@ -15,8 +15,8 @@ source=(
"$_url/$pkgname"
"$_url/$pkgname.completion"
)
sha512sums=('2964b910708e4f348ead17f5326256c8c3d80b0fabcf6632f5a4eadae3705b5be282637d96875e3be9aad152b8a4844a1e18a02441e4d51548c9c8196a70ea9f'
'74cc392d8c19e3ffc8338c99c8ded6e45eaef3c34bfe5eb39d6b0bbc6ceb23a2a7cf9df410c66ef9a88a42f3dbdd7e9db0aa12addd9622fa3d879199d147f4f6')
sha512sums=('f0fb8a4262176fc75d326ade1693fa9ecb3c1c249eef39a50d5d883463b1a7bb1f6b9e4496ca21a4d366cfe894ae7029bb8f0580febad2dfaa46476b33199e5f'
'a3748d6dcef811e416b1e7dab2675f97bafde99063b6a85c1110a497d17acbdc0f6070b45c62f94c52ae97a36fcb37e012d0b5866d120e30b3c69adee0b7750d')
package() {
install -Dm755 $pkgname $pkgdir/usr/bin/$pkgname
+31 -41
View File
@@ -3,11 +3,13 @@
# Show info about pacman history.
#
DIE() { echo "Error: $@" >&2 ; Usage ; exit 1 ; }
echo2() { echo "$@" >&2 ; }
DIE() { echo2 "Error: $@" ; Usage ; exit 1 ; }
WARN() { echo2 "Warning: $@" ; }
ArgVal() { echo "${1#*=}" ; }
Usage() {
local progname="$(basename $0)"
local progname="${0##*/}"
cat <<EOF >&2
$progname: shows history information about package operations.
@@ -17,10 +19,9 @@ Usage: $progname [options] [operation] [package]
options: -h | --help This help.
--no-pkgchk Do not pre-check the existence of the given package.
--no-pager Do not use a pager for the output.
--everything
-everything Show all contents of pacman.log. Lots of material!
--everything Show all contents of pacman.log. Lots of material!
operation: One of: $(Main --operations).
operation: One of: $(Main --operations)
Default: all operations.
Tip: press the Tab key to complete the word!
@@ -34,14 +35,13 @@ Examples:
pahis --upgraded firefox # shows info about firefox updates
pahis --installed # shows info about installed packages
pahis --Running # shows info about pacman commands used
pahis geany # shows info about operations on geany
pahis -everything # shows info about all operations
pahis chromium # shows info about operations on package chromium
pahis --everything # shows info about all operations
EOF
}
Main()
{
Main() {
local op=""
local pkg
local output
@@ -63,13 +63,13 @@ Main()
case "$arg" in
--all-options) # supports bash command completion
line="$(Main --operations)"
line+=" --no-pkgchk -h --help --operations --all-options --everything -everything"
line+=" --no-pkgchk -h --help --operations --all-options --everything" # -everything"
echo "$line"
return
;;
--operations)
line="--upgraded --downgraded --installed --removed --reinstalled --Running"
line+=" -upgraded -downgraded -installed -removed -reinstalled -Running"
# line+=" -upgraded -downgraded -installed -removed -reinstalled -Running"
echo "$line"
return
;;
@@ -102,52 +102,42 @@ Main()
done
if [ "$everything" = "yes" ] ; then
output="$(cat $pacmanlog)"
output="$(< $pacmanlog)"
else
if [ -n "$pkg" ] ; then
if [ "$pkg" ] ; then
if [ $pkgchk -eq 1 ] ; then
yay -Si "$pkg" >& /dev/null || DIE "package '$pkg' does not exist."
fi
if [ -n "$op" ] ; then
case "$op" in
Running)
output="$(grep " \[PACMAN\] $op $pkg " $pacmanlog)" ;;
*)
output="$(grep " \[ALPM\] $op $pkg " $pacmanlog)" ;;
esac
else
output="$(grep " \[ALPM\] [a-z]*ed $pkg " $pacmanlog)"
yay -Si "$pkg" &> /dev/null || WARN "package '$pkg' does not exist."
fi
case "$op" in
Running) output="$(grep " \[PACMAN\] $op $pkg " $pacmanlog)" ;;
"") output="$(grep " \[ALPM\] [a-z]*ed $pkg " $pacmanlog)" ;;
*) output="$(grep " \[ALPM\] $op $pkg " $pacmanlog)" ;;
esac
else
if [ -n "$op" ] ; then
case "$op" in
Running)
output="$(grep " \[PACMAN\] $op " $pacmanlog)" ;;
*)
output="$(grep " \[ALPM\] $op " $pacmanlog)" ;;
esac
else
output="$(grep " \[ALPM\] [a-z]*ed " $pacmanlog)"
fi
case "$op" in
Running) output="$(grep " \[PACMAN\] $op " $pacmanlog)" ;;
"") output="$(grep " \[ALPM\] [a-z]*ed " $pacmanlog)" ;;
*) output="$(grep " \[ALPM\] $op " $pacmanlog)" ;;
esac
fi
fi
if [ -n "$output" ] ; then
if [ -n "$pager" ] ; then
if [ "$output" ] ; then
if [ "$pager" ] ; then
echo "$output" | tac | $pager
else
echo "$output" | tac
fi
else
echo "Requested info is not available."
echo "Probable reasons:"
echo " - '$pkg' was never installed"
echo2 "Requested info is not available."
echo2 "Probable reasons:"
echo2 " - '$pkg' was never installed"
case "$op" in
"" | installed) ;;
*) echo " - '$pkg' was never $op" ;;
*) echo2 " - '$pkg' was never $op" ;;
esac
echo " - '$pkg' was installed while installing the system"
echo2 " - '$pkg' was installed while installing the system"
fi
}
+1 -1
View File
@@ -1,7 +1,7 @@
# bash completion for pahis -*- shell-script -*-
__pahis_pkgsInPacmanLog() {
grep "\] \[ALPM\] [a-z]*ed " /var/log/pacman.log | awk '{print $5}'| sort | uniq
grep "\] \[ALPM\] [a-z]*ed " /var/log/pacman.log | awk '{print $4}'| sort -u
}
__log() {