kiss: initial unneeded [ (external command) removal

This commit is contained in:
Dylan Araps 2021-07-19 00:00:41 +03:00
parent 25155b824b
commit e91f582b67
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C
1 changed files with 9 additions and 5 deletions

14
kiss
View File

@ -80,6 +80,10 @@ mkcd() {
mkdir -p "$@" && cd "$1"
}
null() {
case $1 in '') return 1 ;; *) return 0; esac
}
fnr() {
# Replace all occurrences of substrings with substrings. This
# function takes pairs of arguments iterating two at a time
@ -327,7 +331,7 @@ pkg_source_resolve() {
set -- "$1" "$_fnr" "${3%"${3##*[!/]}"}" "$4"
# Git repository.
if [ -z "${2##git+*}" ]; then
if ! null "${2##git+*}"; then
_res=$2
# Remote source (cached).
@ -335,7 +339,7 @@ pkg_source_resolve() {
_res=$src_dir/$1/${3:+"$3/"}${2##*/}
# Remote source.
elif [ -z "${2##*://*}" ]; then
elif ! null "${2##*://*}"; then
_res=url+$2
_des=$src_dir/$1/${3:+"$3/"}${2##*/}
@ -498,7 +502,7 @@ pkg_depends() {
# dependencies are listed first and then the parents in reverse order.
contains "$deps" "$1" || {
# Filter out non-explicit, already installed packages.
[ -z "$3" ] || [ "$2" ] || contains "$explicit" "$1" ||
! null "$3" || null "$2" || contains "$explicit" "$1" ||
! [ -d "$sys_db/$1" ] || return
# Detect circular dependencies and bail out.
@ -975,7 +979,7 @@ pkg_checksums() {
esac
done < "$repo_dir/sources"
sh256 "$@"
null "$1" || sh256 "$@"
}
pkg_verify() {
@ -1703,7 +1707,7 @@ args() {
# Rerun the script as root with a fixed environment if needed. We sadly
# can't run singular functions as root so this is needed.
case $action in a|alternatives|i|install|r|remove)
[ -z "$1" ] || [ -w "$KISS_ROOT/" ] || [ "$uid" = 0 ] || {
! null "$1" || [ -w "$KISS_ROOT/" ] || [ "$uid" = 0 ] || {
as_root env \
HOME="$HOME" \
XDG_CACHE_HOME="$XDG_CACHE_HOME" \