fix: use dynamic bash lookup and stdin message passing for Telegram scripts#158
Merged
frostming merged 2 commits intobubbuild:mainfrom Apr 11, 2026
Merged
Conversation
…cripts - shell_manager.py: replace hardcoded /bin/bash with shutil.which() lookup so it works on FreeBSD (/usr/local/bin/bash) and other non-Linux systems - telegram_send.py / telegram_edit.py: support --message - / --text - to read content from stdin, avoiding shell escaping issues with backticks, $variables, and quotes - SKILL.md: update command templates to prefer stdin piping via heredoc Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 agent sends Telegram messages via
bashtool, the message content is embedded directly in shell command arguments. This causes two issues:Shell escaping failures: Special characters (
',",$,!, backticks) in message content are interpreted by the shell, resulting in truncated messages, variable substitution, or syntax errors likeSyntax error: word unexpected (expecting ")").Hardcoded
/bin/bashpath:shell_manager.pyassumed bash lives at/bin/bash, which fails on FreeBSD where bash is installed at/usr/local/bin/bash.The core problem is architectural: arbitrary text content should never pass through shell interpretation. This is especially problematic with smaller models (e.g. Gemma 31B) that tend to add redundant
/bin/sh -c '...'wrappers, creating nested shell layers that make correct escaping nearly impossible.Changes
src/bub/builtin/shell_manager.py/bin/bashwithshutil.which("bash") or shutil.which("sh")for cross-platform compatibility (Linux, FreeBSD, macOS).src/skills/telegram/scripts/telegram_send.py--message -to read message content from stdin, bypassing shell interpretation entirely.--message 'text'still works as before.src/skills/telegram/scripts/telegram_edit.py--text -to read message content from stdin (same approach astelegram_send.py).src/skills/telegram/SKILL.mdcat << 'EOF' | ... --message -).Test plan
uv run ruff check .passesuv run pytest -q— all tests passshutil.which("bash")correctly resolves/usr/local/bin/bash--message 'text'/--text 'text'usage still works