-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·65 lines (51 loc) · 1.36 KB
/
Copy pathscript.sh
File metadata and controls
executable file
·65 lines (51 loc) · 1.36 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
60
61
62
63
64
65
#!/usr/bin/env bash -e
# So that when a command fails the script exists instead of continuing with the
# rest of the script.
set -o errexit
# When nounset is set. It will make the script fail when accessing unset
# variables.
set -o nounset
# When pipefail is set. This will ensure that a pipeline command is trated as
# failed even if one command in the pipeline fails.
set -o pipefail
# For debugging purposes example `TRACE=1 ./script.sh``
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
COMMANDS_FLAGS="
Help:
In order to pass arguments use '--' after the command like:
npm run script-name -- -f
To enable debug mode set TRACE=1 ex. TRACE=1 ./script.sh
-h|--help: Lists help options
"
# Script arguments
ARGS=""
# Process script flags/arguments
while (( "$#" )); do
case "$1" in
-h|--help)
echo "$COMMANDS_FLAGS"
exit 0
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*) # preserve positional arguments
ARGS="$ARGS $1"
shift
;;
esac
done
# set positional arguments in their proper place
eval set -- "$ARGS"
# Change to the scripts directory
cd "$(dirname "$0")"
# Please functions here
# Main body of the script goes here
main() {
echo "Start your script here."
}
# Call the main function passing in all arguements
main "$@"