aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-28 13:07:10 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-28 13:07:10 +0000
commitbddf2d184755ea2c5818326dab422f1ee7be963d (patch)
tree9e197381bdbd7b08dd36f9506cbec2b5bf602501
parent7e0737673c16699132aa60d564ed731a175885b4 (diff)
downloadcpt-bddf2d184755ea2c5818326dab422f1ee7be963d.tar.gz
kiss: initial a arg
FossilOrigin-Name: 963d2ec5f42f9a5a8f47eb2c709f8adad699798d1f23b646ecf63157b9a9fd68
-rwxr-xr-xkiss18
1 files 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
;;