File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : Starter template for a Bash script
3+ date : 2025-12-30
4+ topics :
5+ - bash
6+ ---
7+
8+ ``` sh
9+ #! /usr/bin/env bash
10+
11+ # Exit immediately if any command exits with non-zero status
12+ set -e
13+ # Exit if an undefined variable is used
14+ set -u
15+ # Fail if any command in a pipeline fails (not just the last one)
16+ set -o pipefail
17+
18+ # Print line at which the script failed, if it failed (due to "set -e").
19+ trap ' print_error "Script failed at line $LINENO"' ERR
20+
21+ # Configuration
22+ SCRIPT_NAME=" $( basename " $0 " ) "
23+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
24+
25+ # Colors for output (optional)
26+ readonly RED=' \033[0;31m'
27+ readonly YELLOW=' \033[1;33m'
28+ readonly CYAN=' \033[0;36m'
29+ readonly NC=' \033[0m' # No Color
30+
31+ print_error () {
32+ echo -e " ${RED} $* ${NC} " >&2
33+ }
34+
35+ print_warn () {
36+ echo -e " ${YELLOW} $* ${NC} " >&2
37+ }
38+
39+ print_title () {
40+ echo -e " ${CYAN} $* ${NC} "
41+ echo
42+ }
43+
44+ # ##########################################################################################
45+ #
46+ # Main Script
47+ #
48+ # ##########################################################################################
49+ ```
You can’t perform that action at this time.
0 commit comments