@@ -805,11 +805,15 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result<utils::ExitCode
805
805
// Ensure that `.buffered()` is never called with 0 as this will cause a hang.
806
806
// See: https://github.com/rust-lang/futures-rs/pull/1194#discussion_r209501774
807
807
if num_channels > 0 {
808
- let multi_progress_bars = if is_a_tty {
809
- MultiProgress :: with_draw_target ( ProgressDrawTarget :: term_like ( Box :: new ( t) ) )
810
- } else {
811
- MultiProgress :: with_draw_target ( ProgressDrawTarget :: hidden ( ) )
812
- } ;
808
+ let multi_progress_bars =
809
+ MultiProgress :: with_draw_target ( match cfg. process . var ( "RUSTUP_TERM_PROGRESS_WHEN" ) {
810
+ Ok ( s) if s. eq_ignore_ascii_case ( "always" ) => {
811
+ ProgressDrawTarget :: term_like ( Box :: new ( t) )
812
+ }
813
+ Ok ( s) if s. eq_ignore_ascii_case ( "never" ) => ProgressDrawTarget :: hidden ( ) ,
814
+ _ if is_a_tty => ProgressDrawTarget :: term_like ( Box :: new ( t) ) ,
815
+ _ => ProgressDrawTarget :: hidden ( ) ,
816
+ } ) ;
813
817
let channels = tokio_stream:: iter ( channels. into_iter ( ) ) . map ( |( name, distributable) | {
814
818
let pb = multi_progress_bars. add ( ProgressBar :: new ( 1 ) ) ;
815
819
pb. set_style (
@@ -869,7 +873,7 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result<utils::ExitCode
869
873
// If we are running in a TTY, we can use `buffer_unordered` since
870
874
// displaying the output in the correct order is already handled by
871
875
// `indicatif`.
872
- let channels = if is_a_tty {
876
+ let channels = if !multi_progress_bars . is_hidden ( ) {
873
877
channels
874
878
. buffer_unordered ( num_channels)
875
879
. collect :: < Vec < _ > > ( )
@@ -884,7 +888,7 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result<utils::ExitCode
884
888
if update_a {
885
889
update_available = true ;
886
890
}
887
- if !is_a_tty {
891
+ if multi_progress_bars . is_hidden ( ) {
888
892
writeln ! ( t. lock( ) , "{message}" ) ?;
889
893
}
890
894
}
0 commit comments