Skip to content

Ignore terminal echo before the command line in typescripts - #245

Merged
rongxin-liu merged 1 commit into
help50from
help50-typescript
Sep 21, 2026
Merged

rongxin-liu merged 1 commit into
help50from
help50-typescript

Conversation

@rongxin-liu

Copy link
Copy Markdown
Contributor

Found while testing the codespace integration (cs50/codespace#196).

Problem. script records everything on the pty, including readline's tab-completion listing and the redrawn prompt, history recall, and Ctrl-R. _help50 treated only the first line of the typescript as the command line, so after grep zzz ind<Tab><Tab>oor.py (a command with no output), the leftover index.html indoor.py plus the redrawn prompt were passed to _helpless as the command's output. In plain cli this is invisible because the default _helpless is silent; in the codespace it showed a help50 button whose message was that junk.

Fix. Drop everything through the first line that ends with the executed command as recorded by history, joining backslash continuations (and stripping their PS2 prompts) along the way. Only what follows is treated as output. If no such line is found, fall back to dropping the first logical line, as before.

Testing. Drove an interactive login shell under a pty with a fake _helpless that logs its argument:

  • tab-completed grep zzz indoor.py (no match): _helpless no longer called
  • history recall via up-arrow of a quiet command: not called
  • cat \ + nothere2: payload is cat: nothere2: No such file or directory, no > prompt
  • 1s, make hello.c, python baz.py: helpers unchanged
  • make smoke passes

script records everything on the pty, including tab-completion listings,
history recall, and redrawn prompts. _help50 dropped only the first line as
the command, so after tab-completing a command with no output, the leftover
echo was treated as its output and passed to _helpless. Now drop everything
through the first line that ends with the command as recorded in history,
joining backslash continuations and their PS2 prompts; fall back to dropping
the first logical line if the command isn't found.
@rongxin-liu rongxin-liu self-assigned this Sep 21, 2026
@rongxin-liu
rongxin-liu merged commit 400e6c1 into help50 Sep 21, 2026
3 checks passed
@rongxin-liu
rongxin-liu deleted the help50-typescript branch September 21, 2026 05:12
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