--- port/port.tcl	2007-10-15 12:05:12.000000000 -0400
+++ /opt/local/bin/port	2007-10-16 03:56:03.000000000 -0400
@@ -135,7 +135,6 @@
 # we're handling errors in a soft fashion, in which
 # case we continue
 proc fatal_softcontinue s {
-    global global_options
     if {[macports::global_option_isset ports_force]} {
         ui_error $s
         return -code continue
@@ -149,7 +148,6 @@
 # we're handling errors in a soft fashion, in which
 # case we continue
 proc break_softcontinue { msg status name_status } {
-    global ui_options
     upvar $name_status status_var 
     ui_error $msg
     if {[macports::ui_isset ports_processall]} {
@@ -232,7 +230,7 @@
 
 proc add_to_portlist {listname portentry} {
     upvar $listname portlist
-    global global_options global_variations
+    global global_options
 
     # The portlist currently has the following elements in it:
     #   url             if any
@@ -247,6 +245,7 @@
     if {![info exists port(name)]}      { set port(name) "" }
     if {![info exists port(version)]}   { set port(version) "" }
     if {![info exists port(variants)]}  { set port(variants) "" }
+    #WARNING: Do I need to poll global_options and/or private_options?
     if {![info exists port(options)]}   { set port(options) [array get global_options] }
 
     # If neither portname nor url is specified, then default to the current port
@@ -484,7 +483,7 @@
 
 
 proc get_outdated_ports {} {
-    global macports::registry.installtype ui_options
+    global macports::registry.installtype
     set is_image_mode [expr 0 == [string compare "image" ${macports::registry.installtype}]]
 
     # Get the list of installed ports
@@ -988,6 +987,7 @@
     
     set portversion ""
     array unset portoptions
+    #WARNING: Do I need to poll global_options and/or private_options?
     array set portoptions [array get global_options]
     array unset portvariants
     
@@ -1073,7 +1073,6 @@
 
 
 proc action_info { action portlist opts } {
-    global ui_options
     set status 0
     require_portlist portlist
     foreachport $portlist {
@@ -1426,7 +1425,6 @@
 
 
 proc action_uninstall { action portlist opts } {
-    global global_options
     set status 0
     if {[macports::global_option_isset port_uninstall_old]} {
         # if -u then uninstall all inactive ports
@@ -1450,12 +1448,12 @@
 
 
 proc action_installed { action portlist opts } {
-    global global_options
+    global private_options
     set status 0
     set restrictedList 0
     set ilist {}
     
-    if { [llength $portlist] || ![macports::global_option_isset ports_no_args]} {
+    if { [llength $portlist] || ![info exists private_options(ports_no_args)] } {
         set restrictedList 1
         foreachport $portlist {
             set composite_version [composite_version $portversion [array get variations]]
@@ -1502,7 +1500,7 @@
 
 
 proc action_outdated { action portlist opts } {
-    global macports::registry.installtype ui_options global_options
+    global macports::registry.installtype private_options
     set is_image_mode [expr 0 == [string compare "image" ${macports::registry.installtype}]]
 
     set status 0
@@ -1510,7 +1508,7 @@
     # If port names were supplied, limit ourselves to those ports, else check all installed ports
     set ilist {}
     set restrictedList 0
-    if { [llength $portlist] || ![macports::global_option_isset ports_no_args]} {
+    if { [llength $portlist] || ![info exists private_options(ports_no_args)] } {
         set restrictedList 1
         foreach portspec $portlist {
             array set port $portspec
@@ -1756,9 +1754,9 @@
 
 
 proc action_search { action portlist opts } {
-    global global_options
+    global private_options
     set status 0
-    if {![llength $portlist] && [macports::global_option_isset ports_no_args]} {
+    if {![llength $portlist] && [info exists private_options(ports_no_args)]} {
         ui_error "You must specify a search pattern"
         return 1
     }
@@ -1805,11 +1803,11 @@
 
 
 proc action_list { action portlist opts } {
-    global global_options
+    global private_options
     set status 0
     
     # Default to list all ports if no portnames are supplied
-    if {![llength $portlist] && [macports::global_option_isset ports_no_args]} {
+    if { ![llength $portlist] && [info exists private_options(ports_no_args)] } {
         add_to_portlist portlist [list name "-all-"]
     }
     
@@ -2194,6 +2192,7 @@
 #   (2) Following each command (to parse options that will be unique to that command
 #       (the global_options array is reset to global_options_base prior to each command)
 #
+#WARNING: prototype might need to change!
 proc parse_options { action ui_options_name global_options_name } {
     upvar $ui_options_name ui_options
     upvar $global_options_name global_options
@@ -2304,7 +2303,7 @@
 
 proc process_cmd { argv } {
     global cmd_argc cmd_argv cmd_argn
-    global global_options global_options_base ui_options
+    global global_options global_options_base private_options ui_options
     global current_portdir
     set cmd_argv $argv
     set cmd_argc [llength $argv]
@@ -2332,11 +2331,13 @@
         cd $current_portdir
         
         # Reset global_options from base before each action, as we munge it just below...
+        #WARNING: Do I need to poll global_options and/or private_options?
         array set global_options $global_options_base
         
         # Parse options that will be unique to this action
         # (to avoid abiguity with -variants and a default port, either -- must be
         # used to terminate option processing, or the pseudo-port current must be specified).
+        #WARNING: prototype might need to change!
         parse_options $action ui_options global_options
         
         # Parse action arguments, setting a special flag if there were none
@@ -2346,7 +2347,7 @@
         switch -- [lookahead] {
             ;       -
             _EOF_ {
-                set global_options(ports_no_args) yes
+                set private_options(ports_no_args) yes
             }
             default {
                 # Parse port specifications into portlist
@@ -2361,6 +2362,7 @@
         # Find an action to execute
         set action_proc [find_action_proc $action]
         if { $action_proc != "" } {
+        #WARNING: Do I need to poll global_options and/or private_options?
             set action_status [$action_proc $action $portlist [array get global_options]]
         } else {
             puts "Unrecognized action \"$action\""
@@ -2473,7 +2475,7 @@
 
 
 proc process_command_file { in } {
-    global current_portdir ui_options
+    global current_portdir
 
     # Initialize readline
     set isstdin [string match $in "stdin"]
@@ -2539,7 +2541,6 @@
 
 
 proc process_command_files { filelist } {
-    global ui_options
     set exit_status 0
 
     # For each file in the command list, process commands
@@ -2579,11 +2580,14 @@
 # Main
 ##########################################
 
-# globals
+# Global arrays used by the macports1.0 layer
 array set ui_options        {}
 array set global_options    {}
 array set global_variations {}
 
+# Global options private to this script
+array set private_options {}
+
 # Save off a copy of the environment before mportinit monkeys with it
 global env boot_env
 array set boot_env [array get env]
@@ -2608,6 +2612,7 @@
 }
 
 # Parse global options that will affect all subsequent commands
+#WARNING: prototype might need to change!
 parse_options "global" ui_options global_options
 
 # Get arguments remaining after option processing
@@ -2634,6 +2639,7 @@
 
 # Freeze global_options into global_options_base; global_options
 # will be reset to global_options_base prior to processing each command.
+#WARNING: Do I need to poll global_options and/or private_options?
 global global_options_base
 set global_options_base [array get global_options]
 
