Skip to content

Stdin mode doesn't check isatty() — can hang on accidental terminal input #49

Description

@jlevy

Summary

When no file paths are provided and stdin is a terminal (not a pipe), repren silently enters stdin mode and blocks waiting for input. This is confusing when a user simply forgets to provide file arguments.

Details

In repren.py (around line 1603), stdin mode is activated when len(options.root_paths) == 0. There is no check for whether stdin is actually a pipe or a terminal.

Compare with common Unix tools like cat which also read from stdin by default — but unlike cat, repren's purpose is primarily file processing, so accidentally entering stdin mode is more likely to be a mistake.

Suggestion

When stdin is a terminal (not piped), print a helpful message to stderr before reading, e.g.:

repren: reading from stdin (use Ctrl-D to end input, or provide file paths)

Or, more aggressively, refuse to read from a terminal and print a usage hint:

repren: error: no paths provided and stdin is a terminal
Run `repren --help` for usage.

The Rust port (repren-rs) uses std::io::IsTerminal to detect this case and prints a hint.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions