Skip to content

Commit aa38bd2

Browse files
committed
Fix #1938 comments
1 parent 0e128a9 commit aa38bd2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lychee-bin/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#![deny(missing_docs)]
6060

6161
use std::fs::{self, File};
62-
use std::io::{self, BufRead, BufReader, ErrorKind, IsTerminal};
62+
use std::io::{self, BufRead, BufReader, ErrorKind, IsTerminal, stdin};
6363
use std::path::PathBuf;
6464

6565
use anyhow::{Context, Error, Result};
@@ -311,11 +311,11 @@ async fn run(opts: &LycheeOptions) -> Result<i32> {
311311
//
312312
// When stdin is piped (`cat links.txt | lychee -`), `is_terminal()` returns
313313
// false, so the progress bar is shown normally.
314-
let stdin_input = inputs.len() == 1
314+
let is_stdin_input = inputs.len() == 1
315315
&& inputs
316316
.iter()
317317
.any(|input| matches!(input.source, lychee_lib::InputSource::Stdin))
318-
&& std::io::stdin().is_terminal();
318+
&& stdin().is_terminal();
319319

320320
// TODO: Remove this section after `--base` got removed with 1.0
321321
let base = match (opts.config.base.clone(), opts.config.base_url.clone()) {
@@ -384,7 +384,7 @@ async fn run(opts: &LycheeOptions) -> Result<i32> {
384384
cache,
385385
requests,
386386
cfg: opts.config.clone(),
387-
stdin_input,
387+
stdin_input: is_stdin_input,
388388
};
389389

390390
let exit_code = if opts.config.dump {

lychee-lib/src/types/input/input.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{ErrorKind, LycheeResult};
1313
use async_stream::try_stream;
1414
use futures::stream::{Stream, StreamExt};
1515
use log::debug;
16+
use std::io::IsTerminal;
1617
use std::path::{Path, PathBuf};
1718
use tokio::io::{AsyncReadExt, stdin};
1819

@@ -271,7 +272,9 @@ impl Input {
271272
let mut content = String::new();
272273
let mut stdin = stdin();
273274

274-
debug!("Reading content from stdin"); // useful info when nothing piped and process blocks
275+
if std::io::stdin().is_terminal() {
276+
debug!("Reading content from stdin"); // useful info when nothing piped and process blocks
277+
}
275278
stdin.read_to_string(&mut content).await?;
276279

277280
let input_content = InputContent {

0 commit comments

Comments
 (0)