Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/util.inc.sh
blob: ddd7592a11baea3a7bec350942246a516e449e9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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" "$_" || map_r=1
  done
  return $map_r
}

in_array() {
  local item needle=$1

  for item in "${@:2}"; do
    [[ $item = "$needle" ]] && return 0
  done

  return 1
}

quiet_git() {
  local q

  [[ $ASP_GIT_QUIET ]] && q=('-q')

  command git "$1" "${q[@]}" "${@:2}"
}