MCPcopy Index your code
hub / github.com/shareAI-lab/learn-claude-code / run_bash

Function run_bash

agents/s12_worktree_task_isolation.py:485–501  ·  view source on GitHub ↗
(command: str)

Source from the content-addressed store, hash-verified

483
484
485def run_bash(command: str) -> str:
486 dangerous = ["rm -rf /", "sudo", "shutdown", "reboot", "> /dev/"]
487 if any(d in command for d in dangerous):
488 return "Error: Dangerous command blocked"
489 try:
490 r = subprocess.run(
491 command,
492 shell=True,
493 cwd=WORKDIR,
494 capture_output=True,
495 text=True,
496 timeout=120,
497 )
498 out = (r.stdout + r.stderr).strip()
499 return out[:50000] if out else "(no output)"
500 except subprocess.TimeoutExpired:
501 return "Error: Timeout (120s)"
502
503
504def run_read(path: str, limit: int = None) -> str:

Callers 1

Calls 1

runMethod · 0.45

Tested by

no test coverage detected