-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path26-debugging.sh
More file actions
34 lines (26 loc) · 707 Bytes
/
26-debugging.sh
File metadata and controls
34 lines (26 loc) · 707 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
#!/bin/bash
echo "
###############################################
## Example 26.1: #
## set -x shows every line of code that's run #
###############################################
"
set -x
echo 'hi'
for i in $(seq 1 5)
do
echo $i
done
set +x # undo the set -x
echo "
###############################################
## Example 26.2: #
## trap lets us make a fancy step debugger #
###############################################
"
trap '(read -p "[$BASH_SOURCE:$LINENO] $BASH_COMMAND ") ' DEBUG
echo "it makes us press enter to confirm before every line of code"
for i in $(seq 1 5)
do
echo $i
done