From bddf2d184755ea2c5818326dab422f1ee7be963d Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Tue, 28 Jan 2020 13:07:10 +0000 Subject: kiss: initial a arg FossilOrigin-Name: 963d2ec5f42f9a5a8f47eb2c709f8adad699798d1f23b646ecf63157b9a9fd68 --- kiss | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/kiss b/kiss index 87fc41e..a6a013d 100755 --- a/kiss +++ b/kiss @@ -821,6 +821,17 @@ pkg_conflicts() { set -e } +pkg_swap() { + # Check to see if the package is installed. This + # will exit with an error if it is not. + pkg_list "$1" >/dev/null + + alt=$(printf %s "$1$2" | sed 's|/|>|g') + + [ -f "$sys_db/../choices/$alt" ] || + die "Alternative '$1 $2' doesn't exist" +} + pkg_remove() { # Remove a package and all of its files. The '/etc' directory # is handled differently and configuration files are *not* @@ -1170,11 +1181,8 @@ args() { case $action in a|alternatives) if [ "$1" ]; then - # Check to see if the package is installed. This - # will exit with an error if it is not. - pkg_list "$1" >/dev/null + pkg_swap "$@" - [ "$2" ] || die "No alternative chosen" else log "Alternatives:" @@ -1188,7 +1196,7 @@ args() { # name for listing. (pkg_name>usr>bin>ls) for pkg in *; do [ -f "$pkg" ] && - printf '%s\n' "$pkg" | sed 's|>|: /|;s|>|/|g' + printf '%s\n' "$pkg" | sed 's|>| /|;s|>|/|g' done fi ;; -- cgit v1.2.3