Closed rogard closed 6 months ago
$ alias throw
alias throw='__EXCEPTION_TYPE__=${e:-Manually invoked} command_not_found_handle'
The export command below is necessary in my setup in order to get the call stack to produces visible output. However, the predicate UI.Color.IsAvailable
seems too strong, because the terminal does allow for colorized fonts by default. Further, it's unfortunate that the fallback mechanism outputs blank lines.
Colors.sh
alias UI.Color.IsAvailable='[ $(tput colors 2>/dev/null || echo 0) -ge 16 ] && [ -t 1 ]'
if UI.Color.IsAvailable
then
alias UI.Color.Default="echo \$'\033[0m'"
# truncated code
else
alias UI.Color.Default="echo"
# truncated code
fi
Terminal:
$ source tangled.sh
$ alias UI.Color.IsAvailable
alias UI.Color.IsAvailable='[ $(tput colors 2>/dev/null || echo 0) -ge 16 ] && [ -t 1 ]'
$ UI.Color.IsAvailable && echo 'true' || echo 'false'
false
$ tput colors
tput: No value for $TERM and no -T specified
$ echo $TERM
dumb
$ export TERM=xterm-256color
$ source tangled.sh
x UNCAUGHT EXCEPTION: Undefined command (echoo)
|} * Undefined command [tangled.sh:20]
|} x echoo [tangled.sh:20]
This solves the problem permanently:
~/.bashrc
TERM=xterm-256color; export TERM # added
Under the section in the title one reads:
"You may also force an error by throwing your own Exception:"
e="The hard disk is not connected properly!" throw
Is there really supposed to be no
;
between the two instructions? Executing it outputs several blank lines whereas I expected a "call stack". I don't know how to interpret the trace fromset -x
.Please provide some troubleshooting guidance.
tangled.sh
Terminal:
Excerpt from ~/Desktop/log
In full: https://pastebin.com/3TpPKGBB https://pastebin.com/cppu98uZ