jlevy / jlevy/repren

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

Open
#49 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
374
Forks
39
Avg merge
3m
Merged PRs (30d)
1

Description

## 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.