Adds duck-based help50 - don't merge yet
TODOs
- [ ] Remove backspaces from
txt, as viacol -borsed - [ ] Handle ctl-A and ctl-E
- [ ] Hide
[1] Done...messages when backgrounded process ends, as withset +m - [ ] Hitting Enter alone at Bash prompt results in message to duck
- [ ] Have Bash script exit early on any errors, as with
set -e - [ ] Determine why ctl-d yielded below parent shell
How to Try
-
Run:
sudo apt update && sudo apt install -y colorized-logs -
Run:
sudo wget https://raw.githubusercontent.com/cs50/codespace/help50/etc/profile.d/duck.sh -P /etc/profile.d/ -
Open new terminal and run a command that yields a non-0 exit status (e.g.,
cd foo)
Screenshot
Implementation Details
- Uses
scriptcommand to capture all stdin/stdout/stderr in a temp file, so that it can optionally be accessed after a command runs. - Has access to (but doesn't currently use):
- Specific
argvrun, fromhistory - HTML-colored version of stdout/stderr, in case helpful for duck [currently using just text]
- ANSI-colored version of stdout/stderr, in case helpful for duck [currently using just text]
$PWDin which command was run- File tree relative to
$CODESPACE_VSCODE_FOLDERin case helpful forcd, etc.
- Specific
Works as expected. The only glitch I noticed is that the first error I did after opening a new tab did not trigger the ddb. Perhaps I was too quick?
/usr/bin/ld: /lib/x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [<builtin>: dictionary] Error 1
speller/ $ make dictionary
/usr/bin/ld: /lib/x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [<builtin>: dictionary] Error 1
[1]+ Done command50 ddb50.ask "$prompt"
speller/ $
did also notice that sometimes, the message send to ddb (and shown in the box) has unprintable chars overwriting some of it, like
Explain this error:
$ bavalgrind a valgrind: a: command not found
or
Explain this error:
$ jvalgrind valgrind: no program specified valgrind: Use --help for more information.
The duck was still able to interpret correctly though.
edit to add I reproduced the "duck doesn't get the error" problem from before. It happens if the duck sidebar isn't already opened. I switched to the explorer, then had an error in the terminal. The duck sidebar opened, but the error message was never sent to it.