blob: 1a1f85959cfd33a8a5a820319052b328de47ed44 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/bin/bash
. pbs-plumb-shlib
##
# Usage: list FILE
# stdout: A newline-separated list of settings in FILE
##
list() {
[[ $# != 1 ]] && { usage; return 1; }
local file=$1
git config --file "$file" -z --list | awk -vRS='\0' -vFS='\n' '{ print $1 }' && return $PIPESTATUS
}
##
# Usage: get FILE SETTING
# stdout: The raw value of SETTING in FILE; *not* terminated by a newline
##
get() {
[[ $# != 2 ]] && { usage; return 1; }
local file=$1
local setting=$2
git config --file "$file" -z --get "$setting"
}
usage() {
echo "Usage: ${0##*/} COMMAND [-h] [COMMAND-ARGUMENTS]"
echo 'Work with `/etc/libretools.d/pbs-convert.conf`.'
echo
echo "Commands:"
echo " list List the variables set in the file"
echo " get VARNAME Get the value of VARNAME"
echo
echo 'Options:'
echo ' -h Show this message'
}
main() {
in_array '-h' "$@" && { usage; return 0; }
[[ $# < 1 ]] && { usage >&2; return 1; }
local cmd=$1
shift
local file="/etc/libretools.d/pbs-convert.conf"
case "$cmd" in
list)
list "$file" "$@"
return $?;;
get)
get "$file" "$@"
return $?;;
*)
usage >&2
return 1;;
esac
}
main "$@"
|