@@ -25,7 +25,13 @@ module ScriptService =
2525 if trimmed.Contains( " tty -s" ) ||
2626 trimmed.Contains( " [ -t 0 ]" ) ||
2727 trimmed.Contains( " [[ -t 0 ]]" ) ||
28- trimmed.Contains( " if tty" ) then
28+ trimmed.Contains( " if tty" ) ||
29+ trimmed.Contains( " test -t 0" ) ||
30+ trimmed.Contains( " [ -t 1 ]" ) ||
31+ trimmed.Contains( " [[ -t 1 ]]" ) ||
32+ trimmed.Contains( " test -t 1" ) ||
33+ trimmed.Contains( " isatty" ) ||
34+ trimmed.Contains( " stdin is not a TTY" ) then
2935 " # TTY check disabled for .app bundle execution: " + line
3036
3137 // Force non-interactive mode for package managers
@@ -50,21 +56,43 @@ module ScriptService =
5056 elif trimmed.Contains( " command -v brew" ) then
5157 line + " 2>/dev/null"
5258
59+ // Handle common non-interactive mode messages
60+ elif trimmed.Contains( " Running in non-interactive mode" ) then
61+ " # " + line + " # Suppressed for GUI execution"
62+
5363 else
5464 line)
5565
56- // Add non-interactive environment setup at the beginning
66+ // Add comprehensive non-interactive environment setup at the beginning
5767 let header = """ #!/bin/bash
68+ # Force non-interactive mode for GUI execution
5869export TERM=${TERM:-xterm-256color}
70+ export DEBIAN_FRONTEND=noninteractive
71+ export CI=true
72+ export NONINTERACTIVE=1
73+ export FORCE_NONINTERACTIVE=1
5974export HOMEBREW_NO_ENV_HINTS=1
6075export HOMEBREW_NO_INSTALL_CLEANUP=1
6176export HOMEBREW_NO_AUTO_UPDATE=1
77+ export HOMEBREW_NO_ANALYTICS=1
78+ export HOMEBREW_NO_INSECURE_REDIRECT=1
6279
63- # Disable TTY-related functions that cause issues
80+ # Override TTY-related functions and commands that cause issues
6481function tty() {
6582 return 1 # Always return "not a TTY"
6683}
6784
85+ function isatty() {
86+ return 1 # Always return "not a TTY"
87+ }
88+
89+ # Redirect stdin from /dev/null to ensure non-interactive behavior
90+ exec < /dev/null
91+
92+ # Set bash options for non-interactive execution
93+ set +o posix # Disable POSIX mode which can cause TTY issues
94+ set +m # Disable job control
95+
6896"""
6997
7098 // Combine header with processed script content
@@ -328,8 +356,28 @@ function tty() {
328356 // Use osascript to run the script with elevated privileges
329357 // Note: osascript doesn't provide real-time output, so we'll get all output at the end
330358
331- // Create a wrapper script that sets environment and runs the main script
332- let wrapperScript = sprintf " #!/bin/bash\n export TERM=xterm-256color\n export HOMEBREW_NO_ENV_HINTS=1\n export HOMEBREW_NO_INSTALL_CLEANUP=1\n export HOMEBREW_NO_AUTO_UPDATE=1\n exec \" %s \"\n " tempFilePath
359+ // Create a wrapper script that sets comprehensive environment and runs the main script
360+ let wrapperScript =
361+ " #!/bin/bash\n " +
362+ " export TERM=xterm-256color\n " +
363+ " export DEBIAN_FRONTEND=noninteractive\n " +
364+ " export CI=true\n " +
365+ " export NONINTERACTIVE=1\n " +
366+ " export FORCE_NONINTERACTIVE=1\n " +
367+ " export HOMEBREW_NO_ENV_HINTS=1\n " +
368+ " export HOMEBREW_NO_INSTALL_CLEANUP=1\n " +
369+ " export HOMEBREW_NO_AUTO_UPDATE=1\n " +
370+ " export HOMEBREW_NO_ANALYTICS=1\n " +
371+ " export HOMEBREW_NO_INSECURE_REDIRECT=1\n " +
372+ " \n " +
373+ " # Override TTY functions for elevated execution\n " +
374+ " function tty() { return 1; }\n " +
375+ " function isatty() { return 1; }\n " +
376+ " \n " +
377+ " # Redirect stdin from /dev/null\n " +
378+ " exec < /dev/null\n " +
379+ " \n " +
380+ sprintf " exec \" %s \"\n " tempFilePath
333381
334382 let wrapperPath = tempFilePath + " _wrapper.sh"
335383 File.WriteAllText( wrapperPath, wrapperScript)
@@ -436,18 +484,18 @@ function tty() {
436484 startInfo.RedirectStandardOutput <- true
437485 startInfo.RedirectStandardError <- true
438486
439- // Set environment variables to handle non-TTY execution
487+ // Set comprehensive environment variables to handle non-TTY execution
440488 startInfo.EnvironmentVariables.[ " TERM" ] <- " xterm-256color"
441489 startInfo.EnvironmentVariables.[ " DEBIAN_FRONTEND" ] <- " noninteractive"
442490 startInfo.EnvironmentVariables.[ " CI" ] <- " true"
491+ startInfo.EnvironmentVariables.[ " NONINTERACTIVE" ] <- " 1"
492+ startInfo.EnvironmentVariables.[ " FORCE_NONINTERACTIVE" ] <- " 1"
443493 startInfo.EnvironmentVariables.[ " HOMEBREW_NO_ENV_HINTS" ] <- " 1"
444494 startInfo.EnvironmentVariables.[ " HOMEBREW_NO_INSTALL_CLEANUP" ] <- " 1"
445495 startInfo.EnvironmentVariables.[ " HOMEBREW_NO_AUTO_UPDATE" ] <- " 1"
446- startInfo.EnvironmentVariables.[ " NONINTERACTIVE" ] <- " 1"
496+ startInfo.EnvironmentVariables.[ " HOMEBREW_NO_ANALYTICS" ] <- " 1"
497+ startInfo.EnvironmentVariables.[ " HOMEBREW_NO_INSECURE_REDIRECT" ] <- " 1"
447498
448- // Force scripts to run in non-interactive mode
449- startInfo.EnvironmentVariables.[ " FORCE_NONINTERACTIVE" ] <- " 1"
450-
451499 let proc = Process.Start( startInfo)
452500
453501 if proc <> null then
@@ -594,13 +642,15 @@ function tty() {
594642 startInfo.RedirectStandardOutput <- true
595643 startInfo.RedirectStandardError <- true
596644
597- // Set environment variables to handle non-TTY execution
645+ // Set comprehensive environment variables to handle non-TTY execution
598646 startInfo.EnvironmentVariables.[ " TERM" ] <- " xterm-256color"
599647 startInfo.EnvironmentVariables.[ " DEBIAN_FRONTEND" ] <- " noninteractive"
600648 startInfo.EnvironmentVariables.[ " CI" ] <- " true"
601649 startInfo.EnvironmentVariables.[ " HOMEBREW_NO_ENV_HINTS" ] <- " 1"
602650 startInfo.EnvironmentVariables.[ " HOMEBREW_NO_INSTALL_CLEANUP" ] <- " 1"
603651 startInfo.EnvironmentVariables.[ " HOMEBREW_NO_AUTO_UPDATE" ] <- " 1"
652+ startInfo.EnvironmentVariables.[ " HOMEBREW_NO_ANALYTICS" ] <- " 1"
653+ startInfo.EnvironmentVariables.[ " HOMEBREW_NO_INSECURE_REDIRECT" ] <- " 1"
604654 startInfo.EnvironmentVariables.[ " NONINTERACTIVE" ] <- " 1"
605655
606656 // Force scripts to run in non-interactive mode
0 commit comments