-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreference-sane.bash
More file actions
executable file
·59 lines (55 loc) · 1.53 KB
/
reference-sane.bash
File metadata and controls
executable file
·59 lines (55 loc) · 1.53 KB
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
#!/usr/bin/env bash
set -eEuo pipefail -o errtrace -o functrace
shopt -s inherit_errexit 2>/dev/null || true
export PS4='+(${BASH_SOURCE[0]}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
# shellcheck disable=SC2154
trap 'e=$?; set +x; s() { local i=0; while caller $i; do ((++i)); done | while read l f p; do echo "bash: *** [$p:$l $f]${e:+ Error }$e"; e=""; done; }; >&2 echo; >&2 s' ERR # editorconfig-checker-disable-line
# shellcheck disable=SC2145,SC2294
function exe() { printf '%s\n' "$(pwd)\$ $(printf '%q ' "$@")" >&2 && "$@"; }; export -f exe
[[ -z "${VERBOSE:-${V:-}}" ]] || set -x
#- reference-sane.bash 1.0
## Usage: reference-sane.bash
## Description placeholder
##
## -h, --help Display this help and exit
## -v, --version Output version information and exit
function on_exit() {
:
}
trap on_exit EXIT
if { getopt --test >/dev/null 2>&1 && false; } || [[ "$?" = "4" ]] || false; then
ARGS=$(getopt -o hv -l help,version \
-n "$(basename "${BASH_SOURCE[0]}")" -- "$@") ||
{
grep "^##" "${0}" | cut -c 4-
exit 1
}
eval set -- "${ARGS}"
fi
while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
grep "^##" "${0}" | cut -c 4-
exit 0
;;
-v | --version)
grep "^#-" "${0}" | cut -c 4-
exit 0
;;
--)
shift
break
;;
-*)
grep "^##" "${0}" | cut -c 4-
exit 1
;;
*)
break
;;
esac
done
[[ $# -eq 0 ]] || {
grep "^##" "${0}" | cut -c 4-
exit 1
}