Using Bash set -x to Help Debug Why a Script Isn't Working

preview_player
Показать описание
You can run bash -x [YOUR_SCRIPT] or you can set -x in your script to print a trace of info.

Hit the subscribe button to receive more videos like this!

COURSES
---------------------------------------------------
Courses I've created that focus on web dev and deployment topics.

THE TOOLS I USE / GEAR
---------------------------------------------------

FOLLOW ME ELSEWHERE
---------------------------------------------------

TIMESTAMPS
---------------------------------------------------
0:00 -- Intro
0:08 -- Going over the demo script really quick
1:07 -- Running the script to demonstrate the error
2:23 -- It worked manually but not in the script, hmm
3:11 -- How bash -x helps us find the problem within seconds
5:16 -- A few ways to solve this specific error around passing in arguments
6:17 -- Making ShellCheck happy
6:58 -- Parsing arguments and one difference between $* and $@ with Bash
9:09 -- Why I like naming variables instead of using $1, $2 and $@
10:28 -- Using set -x in your Bash script to apply bash -x by default
11:28 -- Does it with work POSIX complaint shell scripts?
Рекомендации по теме
Комментарии
Автор

And having timestamps are fantastic, great work.

s
Автор

This is great for debugging executable bash scripts. But what about debugging sourced bash files? Specifically files that I source in bash, but that also have functions and conditionals/loops inside them? Is there a good debugger for that? I don't feel like I can "bash -x . .bashrc" for example... can I?

EdQuigley