index : asp32 | |
Archlinux32 fork of asp - obsolete | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | asp.in | 30 | ||||
-rw-r--r-- | util.inc.sh | 38 |
@@ -11,7 +11,8 @@ MANPAGES = \ INCLUDES = \ package.inc.sh \ - remote.inc.sh + remote.inc.sh \ + util.inc.sh all: $(BINPROGS) $(MANPAGES) @@ -6,38 +6,10 @@ OPT_ARCH=$(uname -m) OPT_FORCE=0 : ${ASPROOT:=$HOME/asp} +m4_include(util.inc.sh) m4_include(remote.inc.sh) m4_include(package.inc.sh) -log_meta() { - printf "$1 $2\n" "${@:3}" -} - -log_error() { - log_meta 'error:' "$@" >&2 -} - -log_fatal() { - log_error "$@" - exit 1 -} - -log_warning() { - log_meta 'warning:' "$@" >&2 -} - -log_info() { - log_meta '==>' "$@" -} - -map() { - local map_r=0 - for _ in "${@:2}"; do - "$1" "$_" || (( $# > 255 ? map_r=1 : ++r )) - done - return $map_r -} - usage() { cat<<EOF asp [OPTIONS...] {COMMAND} ... diff --git a/util.inc.sh b/util.inc.sh new file mode 100644 index 0000000..a9bb51e --- /dev/null +++ b/util.inc.sh @@ -0,0 +1,38 @@ +log_meta() { + printf "$1 $2\n" "${@:3}" +} + +log_error() { + log_meta 'error:' "$@" >&2 +} + +log_fatal() { + log_error "$@" + exit 1 +} + +log_warning() { + log_meta 'warning:' "$@" >&2 +} + +log_info() { + log_meta '==>' "$@" +} + +map() { + local map_r=0 + for _ in "${@:2}"; do + "$1" "$_" || (( $# > 255 ? map_r=1 : ++r )) + done + return $map_r +} + +in_array() { + local item needle=$1 + + for item in "${@:2}"; do + [[ $item = "$needle" ]] && return 0 + done + + return 1 +} |