[146708] trunk/base/src/port/port.tcl

cal at macports.org cal at macports.org
Tue Mar 15 09:40:00 PDT 2016


Revision: 146708
          https://trac.macports.org/changeset/146708
Author:   cal at macports.org
Date:     2016-03-15 09:40:00 -0700 (Tue, 15 Mar 2016)
Log Message:
-----------
base: Print NL after errors in interactivity

When one of the prompts in the interactivity handling code aborts (due to an
error or a signal), print a newline to ensure the any output that is produced
afterwards (such as error messages) will be printed in the next line.

Modified Paths:
--------------
    trunk/base/src/port/port.tcl

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2016-03-15 16:35:26 UTC (rev 146707)
+++ trunk/base/src/port/port.tcl	2016-03-15 16:40:00 UTC (rev 146708)
@@ -5344,8 +5344,13 @@
 
         signal error {TERM INT}
         while {$timeout >= 0} {
-            if {[catch {set inp [read stdin]} err]} {
-                return -code error "Ctrl-C"
+            try {
+                set inp [read stdin]
+            } catch {*} {
+                # An error occurred, print a newline so the error message
+                # doesn't occur on the prompt line and re-throw
+                puts ""
+                throw
             }
             if {$inp eq "\n"} {
                 return $def
@@ -5444,8 +5449,13 @@
         # User input (probably requires some input error checking code)
         while 1 {
             signal error {TERM INT}
-            if {[catch {set input [gets stdin]} err]} {
-                return -code error "Ctrl-C"
+            try {
+                set input [gets stdin]
+            } catch {*} {
+                # An error occurred, print a newline so the error message
+                # doesn't occur on the prompt line and re-throw
+                puts ""
+                throw
             }
             signal -restart error {TERM INT}
             if {$input in {y Y}} {
@@ -5478,8 +5488,13 @@
             puts -nonewline "Enter a number to select an option: "
             flush stdout
             signal error {TERM INT}
-            if {[catch {set input [gets stdin]} err]} {
-                return -code error "Ctrl-C"
+            try {
+                set input [gets stdin]
+            } catch {*} {
+                # An error occurred, print a newline so the error message
+                # doesn't occur on the prompt line and re-throw
+                puts ""
+                throw
             }
             signal -restart error {TERM INT}
             if {($input <= [llength $ports] && [string is integer -strict $input])} {
@@ -5509,8 +5524,13 @@
             puts -nonewline "Enter the numbers to select the options: "
             flush stdout
             signal error {TERM INT}
-            if {[catch {set input [gets stdin]} err]} {
-                return -code error "Ctrl-C"
+            try {
+                set input [gets stdin]
+            } catch {*} {
+                # An error occurred, print a newline so the error message
+                # doesn't occur on the prompt line and re-throw
+                puts ""
+                throw
             }
             signal -restart error {TERM INT}
             # check if input is non-empty and otherwise fine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160315/0d88c98f/attachment-0001.html>


More information about the macports-changes mailing list