diff --git a/crates/deno_task_shell/src/shell/commands/cat.rs b/crates/deno_task_shell/src/shell/commands/cat.rs index 674fe33..a82e6a5 100644 --- a/crates/deno_task_shell/src/shell/commands/cat.rs +++ b/crates/deno_task_shell/src/shell/commands/cat.rs @@ -3,9 +3,11 @@ use anyhow::Result; use futures::future::LocalBoxFuture; use std::fs::File; +use std::io::IsTerminal; use std::io::Read; use crate::shell::types::ExecuteResult; +use crate::ShellPipeWriter; use super::args::parse_arg_kinds; use super::args::ArgKind; @@ -56,6 +58,14 @@ fn execute_cat(mut context: ShellCommandContext) -> Result { } else { context.stdout.write_all(&buf[..size])?; } + + if let ShellPipeWriter::Stdout = context.stdout { + // check if it's interactive + if buf[size - 1] != b'\n' && std::io::stdout().is_terminal() { + // make sure that we end up on a new line + context.stdout.write_all(b"%\n")?; + } + } }, Err(err) => { context.stderr.write_line(&format!("cat: {path}: {err}"))?;