From ebdd240fd00259d187ee0e6aab43f266b804c3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Mon, 16 Dec 2024 12:51:34 +0100 Subject: [PATCH] Automatically detect terminal mode --- doc/podman-pilot.rst | 5 ++++- podman-pilot/Cargo.toml | 1 + podman-pilot/src/podman.rs | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/podman-pilot.rst b/doc/podman-pilot.rst index de82631..d22bad4 100644 --- a/doc/podman-pilot.rst +++ b/doc/podman-pilot.rst @@ -150,7 +150,10 @@ OPTIONS %interactive - Use when running interactive processes like a shell + Force interactive call style for processes like a shell. + Usually the pilot automatically detects if called in a + terminal or not. This options allows to override the + detection. DEBUGGING --------- diff --git a/podman-pilot/Cargo.toml b/podman-pilot/Cargo.toml index 4ae56b4..0ae1aa8 100644 --- a/podman-pilot/Cargo.toml +++ b/podman-pilot/Cargo.toml @@ -18,3 +18,4 @@ regex = { version = "1.9" } flakes = { version = "3.1.11", path = "../common" } rust-ini = { version = "0.21" } users = { version = "0.11" } +atty = { version = "0.2" } diff --git a/podman-pilot/src/podman.rs b/podman-pilot/src/podman.rs index f05c7c8..9234b1e 100644 --- a/podman-pilot/src/podman.rs +++ b/podman-pilot/src/podman.rs @@ -25,6 +25,8 @@ use crate::defaults; use crate::config::{RuntimeSection, config}; +use atty::Stream; + use flakes::user::{User, mkdir}; use flakes::lookup::Lookup; use flakes::io::IO; @@ -520,7 +522,7 @@ pub fn call_instance( if Lookup::is_debug() { debug!("{:?}", call.get_args()); } - if interactive { + if interactive || atty::is(Stream::Stdout) { call.status()?; } else { match call.output() {