1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-25 16:40:07 -07:00

kiss: contains() fixes and bug fix for repository paths containing spaces.

This commit is contained in:
Dylan Araps 2020-09-26 17:03:13 +03:00
parent fc54435595
commit 8dae372609
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

25
kiss
View File

@ -21,7 +21,15 @@ die() {
} }
contains() { contains() {
case " $1 " in *" $2 "*) return 0; esac; return 1 _sep=${3:- }
case "${_sep}${1}${_sep}" in
*"${_sep}${2}${_sep}"*)
return 0
;;
esac
return 1
} }
prompt() { prompt() {
@ -382,7 +390,7 @@ pkg_depends() {
# After child dependencies are added to the list, # After child dependencies are added to the list,
# add the package which depends on them. # add the package which depends on them.
[ "$2" = explicit ] || deps="$deps $1 " [ "$2" = explicit ] || deps="$deps $1"
} }
} }
@ -574,7 +582,7 @@ pkg_build() {
for pkg do for pkg do
contains "$explicit" "$pkg" || { contains "$explicit" "$pkg" || {
pkg_depends "$pkg" explicit pkg_depends "$pkg" explicit
explicit="$explicit $pkg " explicit="$explicit $pkg"
} }
done done
@ -587,7 +595,7 @@ pkg_build() {
# dependency. # dependency.
for pkg do for pkg do
contains "$deps" "$pkg" || contains "$deps" "$pkg" ||
explicit2=" $explicit2 $pkg " explicit2="$explicit2 $pkg"
done done
explicit=$explicit2 explicit=$explicit2
@ -1198,8 +1206,8 @@ pkg_updates() {
git_root=$(git rev-parse --show-superproject-working-tree) git_root=$(git rev-parse --show-superproject-working-tree)
cd "${git_root:-.}" cd "${git_root:-.}"
contains "$repos" "$PWD" || { contains "$repos" "$PWD" : || {
repos="$repos $PWD " repos="$repos:$PWD"
# Display a tick if signing is enabled for this repository. # Display a tick if signing is enabled for this repository.
case $(git config merge.verifySignatures) in case $(git config merge.verifySignatures) in
@ -1335,7 +1343,8 @@ args() {
case $action in case $action in
a|alternatives|i|install|r|remove) a|alternatives|i|install|r|remove)
[ -z "$1" ] || [ -w "$KISS_ROOT/" ] || [ "$uid" = 0 ] || { [ -z "$1" ] || [ -w "$KISS_ROOT/" ] || [ "$uid" = 0 ] || {
as_root HOME="$HOME" \ as_root \
HOME="$HOME" \
XDG_CACHE_HOME="$XDG_CACHE_HOME" \ XDG_CACHE_HOME="$XDG_CACHE_HOME" \
KISS_CHOICE="$KISS_CHOICE" \ KISS_CHOICE="$KISS_CHOICE" \
KISS_COLOR="$KISS_COLOR" \ KISS_COLOR="$KISS_COLOR" \
@ -1459,7 +1468,7 @@ args() {
name=${file#*/kiss-} name=${file#*/kiss-}
contains "$list" "$name" || { contains "$list" "$name" || {
list=" $list $name " list="$list $name"
printf '%-15s ' "$name" printf '%-15s ' "$name"
sed -n 's/^# *//;2p' "$file" sed -n 's/^# *//;2p' "$file"