Skip to content

Fix help50 bugs and add smoke test - #244

Merged
rongxin-liu merged 2 commits into
help50from
help50-fixes
Sep 21, 2026
Merged

rongxin-liu merged 2 commits into
help50from
help50-fixes

Conversation

@rongxin-liu

Copy link
Copy Markdown
Contributor

Fixes for #210 found while testing the branch, plus a smoke test so they stay fixed. Targets help50, to be merged before #210 lands.

Main changes

Non-interactive login shells hung. cli.sh ran help50 start in every login shell, so bash --login -c ... blocked on script waiting for input. Now only starts in interactive shells with a terminal.

Messages were dropped when stdin was redirected. _ansi and _fold chose between arguments and stdin with -t 0, so valgrind python foo.py < file printed nothing. They now check $#. _fold also falls back to 80 columns when tput cols fails.

Smoke test. tests/smoke.sh runs against a built image under timeouts and checks that non-interactive shells exit, help50's dependencies are installed, and wrappers print with stdin redirected. Runs via make smoke and in CI before the image is pushed. It fails on cs50/cli:latest today (missing ansi2txt), so the checks are live.

Smaller fixes

  • valgrind wrapper called _help, which no longer exists; now sources the lib and uses _alert/_ansi
  • _rhetocial -> _rhetorical typo, so answering y to a suggestion works
  • help50/python: the python dir/file.py branch was dead code; now suggests the right path. realpath needed --canonicalize-missing since the file doesn't exist
  • _helpless payload capped at 8 KiB (downstream ddb50 rejects > 10,000 chars)
  • bsdextrautils installed explicitly for col (was only transitive)
  • Makefile run uses $(IMAGE)

Testing

Overlaid the changes on cs50/cli:latest and drove an interactive login shell under a pty through 1s, make foo.c, cd.., python bar/baz.py, ./foo.c, check 50, y, help50 stop, Ctrl-D. make smoke passes on that image.

Note: the pip help50 currently shipped on cs50/cli:latest fails to import (No module named 'pkg_resources' on Python 3.13), so production help50 is already broken.

- cli.sh: only start help50 in interactive shells with a terminal, else
  non-interactive login shells (bash --login -c) hang on script
- lib/cli: _ansi and _fold take arguments by $#, not -t 0, so messages
  aren't dropped when stdin is redirected; _fold falls back to 80 columns
- valgrind: source lib and use _alert/_ansi instead of undefined _help
- help50.sh: fix _rhetocial typo; cap _helpless payload at 8 KiB
- help50/python: handle python dir/file.py, use realpath --canonicalize-missing
- Dockerfile: install bsdextrautils explicitly for col
tests/smoke.sh checks a built image under timeouts: non-interactive login
shells exit, help50 deps are installed, wrappers print with stdin redirected.
Run via make smoke, and in CI before pushing to Docker Hub.
@rongxin-liu rongxin-liu self-assigned this Sep 21, 2026
@rongxin-liu
rongxin-liu merged commit 04b60f3 into help50 Sep 21, 2026
3 checks passed
@rongxin-liu
rongxin-liu deleted the help50-fixes branch September 21, 2026 01:29
rongxin-liu added a commit that referenced this pull request Sep 30, 2026
Reimplements help50 in Bash, running locally and automatically per login
shell, without a server. Usage is inspired by systemctl:

- help50 start/stop/status/enable/disable/is-enabled control a session
  that logs the shell's I/O via script to /tmp/help50.$PPID
- help50 COMMAND [ARGS...] runs COMMAND as though typed directly, with
  the same exit status
- HELP50_DISABLED in the environment is a kill switch, so that as a
  Codespaces secret help50 can be turned off fleet-wide without a rebuild

/etc/profile.d/help50.sh installs a PROMPT_COMMAND hook that, after a
failed command, strips the typescript of ANSI/control characters and
terminal echo, bounds the read (first 64K + last 1M) and the output
(first 64 + last 1,024 lines), and passes it to each executable helper in
/opt/cs50/lib/help50/ under a 5-second timeout. Helper output is shown via
_helpful; otherwise _helpless receives the output and command line (a
no-op here, overridden in cs50/codespace to relay to the CS50 Duck).

Also adds /opt/cs50/lib/cli helper functions (_alert, _ansi, _find,
_fold, _sure) used by the make, sqlite3, http-server, and valgrind
wrappers; helpers for bash, cd, clang, make, and python; tests/smoke.sh
(make smoke), run in CI against each architecture's build before pushing
to Docker Hub; and installs bsdextrautils, colorized-logs, file, expect,
and fzf, dropping the Python help50 package.

Squashed from 99 commits, including #244, #245, #246, #247, and #248.

Co-authored-by: Rongxin Liu <10591665+rongxin-liu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant