File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ use crate::config::Config;
5555use crate :: error:: Chain ;
5656use crate :: install_progress:: osc94_progress;
5757use crate :: subcommand:: * ;
58+ use crate :: utils:: is_not_normal_terminal;
5859
5960static NOT_DISPLAY_ABORT : AtomicBool = AtomicBool :: new ( false ) ;
6061static LOCKED : AtomicBool = AtomicBool :: new ( false ) ;
@@ -432,8 +433,11 @@ fn try_main(
432433) -> Result < i32 , OutputError > {
433434 init_color_formatter ( & oma, & config) ;
434435
435- let no_progress =
436- oma. global . no_progress || !is_terminal ( ) || oma. global . debug || oma. global . dry_run ;
436+ let no_progress = oma. global . no_progress
437+ || !is_terminal ( )
438+ || oma. global . debug
439+ || oma. global . dry_run
440+ || is_not_normal_terminal ( ) ;
437441
438442 let code = match oma. subcmd {
439443 Some ( subcmd) => subcmd. execute ( & config, no_progress) ,
Original file line number Diff line number Diff line change @@ -295,6 +295,32 @@ pub fn is_ssh_from_loginctl() -> bool {
295295 false
296296}
297297
298+ pub fn is_not_normal_terminal ( ) -> bool {
299+ let p = match std:: fs:: read_link ( "/proc/self/fd/0" ) {
300+ Ok ( p) => p,
301+ Err ( e) => {
302+ debug ! ( "Failed to read symlink /proc/self/fd/0: {e}" ) ;
303+ return true ;
304+ }
305+ } ;
306+
307+ debug ! ( "tty device is: {}" , p. display( ) ) ;
308+
309+ let p = p. to_string_lossy ( ) ;
310+
311+ if p. starts_with ( "/dev/pts" ) {
312+ debug ! ( "tty device is pts" ) ;
313+ return false ;
314+ } else if let Some ( suffix) = p. strip_prefix ( "/dev/tty" )
315+ && suffix. chars ( ) . next ( ) . is_some_and ( |c| c. is_ascii_digit ( ) )
316+ {
317+ debug ! ( "tty device is pure tty" ) ;
318+ return false ;
319+ }
320+
321+ true
322+ }
323+
298324/// oma display normal message
299325#[ macro_export]
300326macro_rules! msg {
You can’t perform that action at this time.
0 commit comments