-
-
Notifications
You must be signed in to change notification settings - Fork 164
Debugging Completion Scripts
andychu edited this page Nov 6, 2018
·
4 revisions
(Back to Contributing)
Context: Running Bash Completion Scripts with OSH
Reading and debugging completion scripts is difficult. Here is a way OSH helps. This can certainly be improved.
It helps to open two tmux panes, or two terminals side-by-side. Then you can type on the left and see debug logs on the right.
$ mkfifo _tmp/debug # named pipe
$ scripts/complete.sh osh-trace # do this on the LEFT. type commands here:
$ cat _tmp/debug # do this on the RIGHT.
For reference, this is the osh-trace function
:
osh-trace() {
env -i OSH_CRASH_DUMP_DIR=_tmp PS4='+[${LINENO}:${FUNCNAME[0]}] ' \
bin/osh -x --debug-file _tmp/debug --xtrace-to-debug-file "$@"
}
It uses -x / xtrace
and $PS4
to display logs. And it redirects -x
output to _tmp/debug
.