https://github.com/Jetchisel/setx
Copyright 2016 Jetchisel
A bash shell script that insert set [+-]x and a PS4 debug code or a trap to make the script execute line by line by using the return key. Shell script is more verbose when the code is added in the script in question. It is quite handy when writing and testing a shell script.
setx [OPTION]... [FILE]
-h --help Show this help.
-a, --about Show a brief info about setx.
-c, --comment Add a # in front of a line.
-r, --remove Remove all the [keyword] code.
-x, --xtrace Add `set -x' code to the second line by default.
-X, --Xtrace Add `set -x' and a `PS4' code at the second line. by default.
-p, --print Print [keyword] code.
-t, --trap Make the execution of the script line by line, defaults to the second line.
-c FILE Add a # in front of all lines.
-c 1 FILE Add a # in front of the first line.
-c 10,20 FILE Add a # in front of lines 10 to 20.
-x FILE Insert `set -x' at the second line of FILE.
-x 5 FILE Insert `set -x' at the fifth line of FILE.
-x 5,10 FILE Insert `set -x' at the fifth line and `set +x' at the 10th.
-x ,10 FILE Insert `set +x' at the 10th line of file.
-X FILE Insert `set -x' and a `PS4' at the second line of FILE.
-X 5 FILE Insert `set -x' and a `PS4' at the fifth line of FILE.
-X 5,10 FILE Insert `set -x' and a `PS4' at the fifth line and `set +x' at the 10th.
-t FILE Insert a trap at the second line of FILE.
-t 5 FILE Insert a trap at the fifth line of FILE.
-p [keyword] FILE Print the [keyword] code if found in FILE.
-r [keyword] FILE Remove all the [keyword] code if found in FILE.
debug All the debug codes `set [+-]x', and the `trap'.
cr All the carriage returns that is normally found in a Dos/Windows file.
comment All the lines that has been commented by adding a # in front.
tspace All the lines that has trailing white space.
Inserting any code inside the case statement for example will surely break its syntax and will add more bugs in the script in question.
If you're fluid with one of the unix file editor such as ex, ed or vim then this script is probably no use to you since everything here can be done in one of those file editor, but until then this script should make your life more easier.
For more info about debugging please have a look at the following site.