Files

7 lines
296 B
Python

import typing
def piped(stdin: typing.TextIO) -> str:
"""The text piped in, empty from a terminal. Claude Code's Bash tool gives a command /dev/null as stdin (readlink /proc/self/fd/0 shows it), so without a heredoc read() returns "" at once."""
return "" if stdin.isatty() else stdin.read()