xpm

x package manager, a uniform interface to various POSIX package managers
git clone git://src.gearsix.net/xpm
Log | Files | Refs | Atom | README

commit a9f84d5d80a1dc2e07f263593e69c384a133650d
parent b9a947bf221cbec0fd6d9cea6a1365cc899de6b5
Author: gearsix <gearsix@tuta.io>
Date:   Thu, 17 Mar 2022 16:44:43 +0000

tidyup: removed TRACK_INSTALLED; TRACK_INSTALLED_FILE -> INSTALLED

Diffstat:
Mxpm.sh | 35+++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/xpm.sh b/xpm.sh @@ -1,32 +1,31 @@ #!/usr/bin/env sh xpm="" -TRACK_INSTALLED=1 -TRACK_INSTALLED_FILE=~/.local/share/xpm/installed.txt +INSTALLED=~/.local/share/xpm/installed.txt # track installed track_installed_add() { - if [ ! -d $(dirname $TRACK_INSTALLED_FILE) ]; then - mkdir -p $(dirname $TRACK_INSTALLED_FILE) + if [ ! -d $(dirname $INSTALLED) ]; then + mkdir -p $(dirname $INSTALLED) fi for pkg in $@; do - if [ "$(grep $pkg $TRACK_INSTALLED_FILE)" = "" ]; then - echo $pkg >> "$TRACK_INSTALLED_FILE" + if [ "$(grep $pkg $INSTALLED)" = "" ]; then + echo $pkg >> "$INSTALLED" else echo "grep" - grep $pkg $TRACK_INSTALLED_FILE + grep $pkg $INSTALLED fi done } track_installed_rm() { for pkg in $@; do - if [ "$(grep $pkg $TRACK_INSTALLED_FILE)" != "" ]; then - sed -i "/$pkg/d" "$TRACK_INSTALLED_FILE" + if [ "$(grep $pkg $INSTALLED)" != "" ]; then + sed -i "/$pkg/d" "$INSTALLED" else echo "grep" - grep $pkg $TRACK_INSTALLED_FILE + grep $pkg $INSTALLED fi done } @@ -37,28 +36,28 @@ unknown_pm() { exit } -set_xpm_install() { +xpm_install() { if [ $(command -v apt) ]; then xpm="sudo apt install" elif [ $(command -v zypper) ]; then xpm="sudo zypper install" elif [ $(command -v xbps-install) ]; then xpm="sudo xbps-install -Rs" else unknown_pm; fi } -set_xpm_remove() { +xpm_remove() { if [ $(command -v apt) ]; then xpm="sudo apt remove" elif [ $(command -v zypper) ]; then xpm="sudo zypper remove" elif [ $(command -v xbps-remove) ]; then xpm="sudo xbps-remove -R" else unknown_pm; fi } -set_xpm_search() { +xpm_search() { if [ $(command -v apt) ]; then xpm="apt search" elif [ $(command -v zypper) ]; then xpm="zypper search" elif [ $(command -v xbps-query) ]; then xpm="xbps-query -Rs" else unknown_pm; fi } -set_xpm_query() { +xpm_query() { if [ $(command -v apt) ]; then xpm="apt list --installed" elif [ $(command -v zypper) ]; then xpm="zypper search --installed-only" elif [ $(command -v xbps-query) ]; then xpm="xbps-query -S" @@ -69,22 +68,22 @@ set_xpm_query() { case "$1" in "i"|"in"|"install") shift - set_xpm_install + xpm_install $xpm $@ && track_installed_add $@ ;; "r"|"rm"|"remove") shift - set_xpm_remove + xpm_remove $xpm $@ && track_installed_rm $@ ;; "s"|"se"|"search") shift - set_xpm_search + xpm_search $xpm $@ ;; "q"|"qry"|"query") shift - set_xpm_query + xpm_query $xpm $@ ;; esac