From 5ad57520c529df949ca5f351a1f4b48130a1dc31 Mon Sep 17 00:00:00 2001 From: Chenfeng Bao Date: Wed, 24 Jul 2024 15:53:41 -0400 Subject: [PATCH] touch up mintty warning message --- src/D2L.Bmx/ConsolePrompter.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/D2L.Bmx/ConsolePrompter.cs b/src/D2L.Bmx/ConsolePrompter.cs index 49c281a0..e52d44bb 100644 --- a/src/D2L.Bmx/ConsolePrompter.cs +++ b/src/D2L.Bmx/ConsolePrompter.cs @@ -163,14 +163,16 @@ private string GetMaskedInput( string prompt ) { if( IS_WINDOWS ) { // On Windows, Console.ReadKey calls native console API, and will fail without a console attached if( Console.IsInputRedirected ) { - Console.Error.WriteLine( """ + if( Environment.GetEnvironmentVariable( "TERM_PROGRAM" ) == "mintty" ) { + Console.Error.WriteLine( "\x1b[93m" + """ ====== WARNING ====== - Input to BMX is redirected. Input may be displayed on screen! - If you're using mintty (with Git Bash, Cygwin, MSYS2 etc.), consider switching - to Windows Terminal for a better experience. + Secret input won't be masked on screen! + This is because you are using mintty (possibly via Git Bash, Cygwin, MSYS2 etc.). + Consider switching to Windows Terminal for a better experience. If you must use mintty, prefix your bmx command with 'winpty '. ===================== - """ ); + """ + "\x1b[0m" ); + } readKey = () => (char)_stdinReader.Read(); } else { readKey = () => Console.ReadKey( intercept: true ).KeyChar;