kiss: initial a arg

This commit is contained in:
Dylan Araps 2020-01-28 15:07:11 +02:00
parent d25c4bd5e1
commit 596c64d447
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 13 additions and 5 deletions

18
kiss
View File

@ -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
;;