-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate_v2.sh
More file actions
43 lines (37 loc) · 780 Bytes
/
Copy pathtemplate_v2.sh
File metadata and controls
43 lines (37 loc) · 780 Bytes
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
#!/usr/bin/env bash
set -eu # StrictMode, e:exit on non-zero status code; u:prevent undefined variable
## Usage display:
#/ Usage:
#/ Description:
#/ Examples:
#/ Options:
#/ --help: Display this help message
usage() {
grep '^#/' "$0" | cut -c4-
exit 0
}
expr "$*" : ".*--help" >/dev/null && usage
## Variables:
SCRIPT_NAME=$(basename "$0")
ARG_1=${1:-"default"}
## Log (add "| tee -a "$LOG_FILE" >&2" to into a file):
readonly LOG_FILE="/tmp/$(basename "$0").log"
info() { echo -e "\033[0;36m[INFO] $*"; }
warning() { echo -e "\033[1;33m[WARNING] $*"; }
error() { echo -e "\033[0;31m[ERROR] $*"; }
## Functions:
my_function() {
return 0
}
## Main
main() {
case "$ARG_1" in
-x | --xxx)
# Script goes here
;;
*)
usage
;;
esac
}
main "$*"