Skip to content

Commit 0339e3a

Browse files
committed
fix: stdin behavior
The issue is that eza ignores the `--stdin` argument, unless there is data piped into it. This is not how stdin behavior is supposed to work. e.g. look at the `cat` command. The flag should tell eza that the input is read from stdin. But if you call `eza --stdin` nothing is read from stdin. This means that the current argument is moot and serves no purpose, because eza already has the capability of checking whether data is piped into it. So eza behaves like this: if you pipe data into eza, eza will ignore the data, unless you additionally specify `--stdin` This makes no sense. This change accomplishes the following: - `eza --stdin` reads from standard input - if data is piped into eza, standard input is automatically read and no `--stdin` flag is required - if data is piped into eza, `--stdin` can still be used BREAKING CHANGE: if data is piped into eza, eza will not ignore it
1 parent 72c2c74 commit 0339e3a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Diff for: src/options/stdin.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ pub enum FilesInput {
2020
impl FilesInput {
2121
pub fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
2222
Ok(
23-
if io::stdin().is_terminal() || !matches.has(&flags::STDIN)? {
24-
FilesInput::Args
25-
} else if matches.has(&flags::STDIN)? && !io::stdin().is_terminal() {
23+
if matches.has(&flags::STDIN)? || !io::stdin().is_terminal() {
2624
let separator = vars
2725
.get(EZA_STDIN_SEPARATOR)
2826
.unwrap_or(OsString::from("\n"));

0 commit comments

Comments
 (0)