forked from aurutils/aurutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aur.in
64 lines (53 loc) · 1.46 KB
/
aur.in
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash -
readonly XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
readonly argv0=aur
readonly aur_version='AURUTILS_VERSION'
readonly lib_dir=${AUR_EXEC_PATH:-'AURUTILS_LIB_DIR'}
shopt -s nullglob
if [[ -z $1 ]]; then
printf >&2 'usage: %s [command]\n\n' "$argv0"
printf >&2 'available commands:\n'
for p in "$lib_dir"/aur-*; do
printf '%q\n' "${p##*/aur-}"
done | column >&2
printf >&2 '\navailable user commands:\n'
compgen -c aur- | sort -u | while IFS= read -r; do
if ! [[ -x $lib_dir/$REPLY ]]; then
printf '%q\n' "${REPLY#aur-}"
fi
done | column >&2
exit 1
fi
# load environment
if [[ -f ${AUR_ENV=$XDG_CONFIG_HOME/aurutils/env} ]]; then
while IFS=' = ' read -r key value; do
case $key in
AUR*) printf -v "$key" '%s' "$value"
export "${key?}" ;;
esac
done < <(pacini "$AUR_ENV")
wait "$!"
fi
if [[ -v AUR_DEBUG ]]; then
printf >&2 'aur version %s\n' "$aur_version"
fi
case $1 in
--version)
printf >&2 'aur version %s\n' "$aur_version"
exit 0 ;;
--env)
printenv | grep -E '(^AUR|PERL5LIB)' | sort >&2
exit 0 ;;
--exec-path)
printf '%s\n' "$lib_dir"
exit 0 ;;
esac
if [[ "$PATH" != "$lib_dir:"* ]]; then
readonly PATH=$lib_dir:$PATH
fi
if type -P "aur-$1" >/dev/null; then
exec "aur-$1" "${@:2}"
else
printf >&2 '%s: %q is not an aur command\n' "$argv0" "$1"
exit 1
fi