changelog: update for issue #1134
[aurutils.git] / aur.in
blob4139e5453e169a0e3ac510d1cbc2fbc6d1225408
1 #!/bin/bash -
2 readonly XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
3 readonly argv0=aur
4 readonly aur_version='AURUTILS_VERSION'
5 readonly lib_dir=${AUR_EXEC_PATH:-'AURUTILS_LIB_DIR'}
6 shopt -s nullglob
8 if [[ -z $1 ]]; then
9 printf >&2 'usage: %s [command]\n\n' "$argv0"
10 printf >&2 'available commands:\n'
12 for p in "$lib_dir"/aur-*; do
13 printf '%q\n' "${p##*/aur-}"
14 done | column >&2
16 printf >&2 '\navailable user commands:\n'
18 compgen -c aur- | sort -u | while IFS= read -r; do
19 if ! [[ -x $lib_dir/$REPLY ]]; then
20 printf '%q\n' "${REPLY#aur-}"
22 done | column >&2
24 exit 1
27 # load environment
28 if [[ -f ${AUR_ENV=$XDG_CONFIG_HOME/aurutils/env} ]]; then
29 while IFS=' = ' read -r key value; do
30 case $key in
31 AUR*) printf -v "$key" '%s' "$value"
32 export "${key?}" ;;
33 esac
34 done < <(pacini "$AUR_ENV")
36 wait "$!"
39 if [[ -v AUR_DEBUG ]]; then
40 printf >&2 'aur version %s\n' "$aur_version"
43 case $1 in
44 --version)
45 printf >&2 'aur version %s\n' "$aur_version"
46 exit 0 ;;
47 --env)
48 printenv | grep -E '(^AUR|PERL5LIB)' | sort >&2
49 exit 0 ;;
50 --exec-path)
51 printf '%s\n' "$lib_dir"
52 exit 0 ;;
53 esac
55 if [[ "$PATH" != "$lib_dir:"* ]]; then
56 readonly PATH=$lib_dir:$PATH
59 if type -P "aur-$1" >/dev/null; then
60 exec "aur-$1" "${@:2}"
61 else
62 printf >&2 '%s: %q is not an aur command\n' "$argv0" "$1"
63 exit 1