fix: prevent shell tool hang with pager-based commands in non-interactive mode#494
Open
xlyoung wants to merge 1 commit into
Open
fix: prevent shell tool hang with pager-based commands in non-interactive mode#494xlyoung wants to merge 1 commit into
xlyoung wants to merge 1 commit into
Conversation
…tive mode When the shell tool runs commands like 'git diff' or 'man' in non-interactive mode, the spawned pager (usually 'less') hangs because: 1. TERM environment variable is not set, so 'less' reports 'WARNING: terminal is not fully functional' 2. The pager waits for user input that never comes Fix: - Set TERM=xterm-256color if not already set (needed for PTY emulation) - In non-interactive mode, disable pagers by setting GIT_PAGER=cat, PAGER=cat, MANPAGER=cat (prevents pager from blocking) Fixes strands-agents#360
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the shell tool runs commands like
git difformanin non-interactive mode, the spawned pager (usuallyless) hangs because:TERMenvironment variable is not set →lessreportsWARNING: terminal is not fully functionalRoot Cause
In
execute_with_pty(), the child process doesn't setTERMor disable pagers:Fix
TERM=xterm-256colorif not already set (needed for PTY emulation)GIT_PAGER=cat,PAGER=cat,MANPAGER=catTesting
All 30 shell tests pass.
Fixes #360