[tor-commits] [tor-browser-bundle/master] Bug 12468: Send script output messages to stderr only in debug mode

mikeperry at torproject.org mikeperry at torproject.org
Thu Mar 26 21:46:41 UTC 2015


commit b734892e76d0fd8d45fbd56da1cede14df8f86a9
Author: Mike Perry <mikeperry-git at torproject.org>
Date:   Wed Mar 18 12:59:08 2015 -0700

    Bug 12468: Send script output messages to stderr only in debug mode
    
    Unity in Ubuntu 14.04 reportedly allocates a pty for use as the stdout and
    stderr of all GUI programs (including programs run from Nautilus), and
    reportedly does not display messages sent to that pty to the user.
    
    This 'feature' of Ubuntu means that complain can no longer rely on any
    terminal to inform the user of an error, unless the user specifically
    requests debugging output using a command-line option.
    
    Based on patches from Robert Ransom in
    https://trac.torproject.org/projects/tor/ticket/12468.
---
 RelativeLink/start-tor-browser |   46 ++++++----------------------------------
 1 file changed, 6 insertions(+), 40 deletions(-)

diff --git a/RelativeLink/start-tor-browser b/RelativeLink/start-tor-browser
index d28c759..31ccb83 100755
--- a/RelativeLink/start-tor-browser
+++ b/RelativeLink/start-tor-browser
@@ -28,32 +28,6 @@ fi
 # Do not (try to) connect to the session manager
 unset SESSION_MANAGER
 
-# Determine whether we are running in a terminal.  If we are, we
-# should send our error messages to stderr...
-ARE_WE_RUNNING_IN_A_TERMINAL=0
-if [ -t 1 -o -t 2 ]; then
-	ARE_WE_RUNNING_IN_A_TERMINAL=1
-fi
-
-# ...unless we're running in the same terminal as startx or xinit.  In
-# that case, the user is probably running us from a GUI file manager
-# in an X session started by typing startx at the console.
-#
-# Hopefully, the local ps command supports BSD-style options.  (The ps
-# commands usually used on Linux and FreeBSD do; do any other OSes
-# support running Linux binaries?)
-ps T 2>/dev/null |grep startx 2>/dev/null |grep -v grep 2>&1 >/dev/null
-not_running_in_same_terminal_as_startx="$?"
-ps T 2>/dev/null |grep xinit 2>/dev/null |grep -v grep 2>&1 >/dev/null
-not_running_in_same_terminal_as_xinit="$?"
-
-# not_running_in_same_terminal_as_foo has the value 1 if we are *not*
-# running in the same terminal as foo.
-if [ "$not_running_in_same_terminal_as_startx" -eq 0 -o \
-     "$not_running_in_same_terminal_as_xinit" -eq 0 ]; then
-	ARE_WE_RUNNING_IN_A_TERMINAL=0
-fi
-
 # Complain about an error, by any means necessary.
 # Usage: complain message
 # message must not begin with a dash.
@@ -61,8 +35,8 @@ complain () {
 	# Trim leading newlines, to avoid breaking formatting in some dialogs.
 	complain_message="`echo "$1" | sed '/./,$!d'`"
 
-	# If we're being run in a terminal, complain there.
-	if [ "$ARE_WE_RUNNING_IN_A_TERMINAL" -ne 0 ]; then
+	# If we're being run in debug mode, complain to stderr.
+	if [ "$debug" -eq 1 ]; then
 		echo "$complain_message" >&2
 		return
 	fi
@@ -136,22 +110,14 @@ elif [ "$#" -ge 1 -a \( "x$1" = "x--help" -o "x$1" = "x-help" \) ]; then
 	exit 0
 fi
 
-# If the user hasn't requested 'debug mode', close whichever of stdout
-# and stderr are not ttys, to keep Firefox and the stuff loaded by/for
-# it (including the system's shared-library loader) from printing
-# messages to $HOME/.xsession-errors .  (Users wouldn't have seen
+# If the user hasn't requested 'debug mode', close stdout and stderr,
+# to keep Firefox and the stuff loaded by/for it (including the
+# system's shared-library loader) from printing messages to
+# $HOME/.xsession-errors or other files. (Users wouldn't have seen
 # messages there anyway.)
-#
-# If the user has requested 'debug mode', don't muck with the FDs.
 if [ "$debug" -ne 1 ]; then
-  if [ '!' -t 1 ]; then
-    # stdout is not a tty
     exec >/dev/null
-  fi
-  if [ '!' -t 2 ]; then
-    # stderr is not a tty
     exec 2>/dev/null
-  fi
 fi
 
 # If XAUTHORITY is unset, set it to its default value of $HOME/.Xauthority





More information about the tor-commits mailing list