Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds duck-based help50 - don't merge yet #101

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
Draft

Adds duck-based help50 - don't merge yet #101

wants to merge 11 commits into from

Conversation

dmalan
Copy link
Member

@dmalan dmalan commented Jul 23, 2023

TODOs

  • Remove backspaces from txt, as via col -b or sed
  • Handle ctl-A and ctl-E
  • Hide [1] Done... messages when backgrounded process ends, as with set +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
Screenshot 2023-07-24 at 12 05 12 PM

How to Try

  1. Run:

     sudo apt update && sudo apt install -y colorized-logs
    
  2. Run:

    sudo wget https://raw.githubusercontent.com/cs50/codespace/help50/etc/profile.d/duck.sh -P /etc/profile.d/
    
  3. Open new terminal and run a command that yields a non-0 exit status (e.g., cd foo)

Screenshot

Screenshot 2023-07-22 at 11 16 51 PM

Implementation Details

  • Uses script command 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 argv run, from history
    • 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]
    • $PWD in which command was run
    • File tree relative to $CODESPACE_VSCODE_FOLDER in case helpful for cd, etc.

@dmalan dmalan added the enhancement New feature or request label Jul 23, 2023
@curiouskiwi
Copy link

curiouskiwi commented Jul 24, 2023

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:
$ ba��valgrind a valgrind: a: command not found

or

Explain this error:
$ j�valgrind 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.

@dmalan dmalan self-assigned this Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

None yet

2 participants