Index: doc/port.1
===================================================================
--- doc/port.1	(revision 135063)
+++ doc/port.1	(working copy)
@@ -462,6 +462,11 @@
 Debug mode, generate debugging messages, implies \-v
 .RE
 .PP
+\-e
+.RS 4
+Enviroment mode, generates environment messages
+.RE
+.PP
 \-q
 .RS 4
 Quiet mode, suppress informational messages to a minimum, implies \-N
Index: doc/port.1.txt
===================================================================
--- doc/port.1.txt	(revision 135063)
+++ doc/port.1.txt	(working copy)
@@ -129,6 +129,9 @@
 -d::
     Debug mode, generate debugging messages, implies -v
 
+-e::
+    Enviroment mode, generates environment messages
+
 -q::
     Quiet mode, suppress informational messages to a minimum, implies -N
 
Index: src/macports1.0/macports.tcl
===================================================================
--- src/macports1.0/macports.tcl	(revision 135063)
+++ src/macports1.0/macports.tcl	(working copy)
@@ -93,6 +93,50 @@
     return ${macports::autoconf::macports_version}
 }
 
+##
+# Return the port environment variables.
+proc macports::environment {} {
+    set mpenv {}
+    if {![macports::ui_isset ports_quiet]} {
+        lappend mpenv "$macports::ui_prefix port_cmd_version:  ${macports::autoconf::macports_version}"
+    } else {
+        lappend mpenv "port_cmd_version  ${macports::autoconf::macports_version}"
+    }
+    if {[info exists macports::bootstrap_options]} {
+        foreach bootstrap_option [lsort $macports::bootstrap_options] {
+            if {[info exists macports::$bootstrap_option]} {
+                if {![macports::ui_isset ports_quiet]} {
+                    lappend mpenv "$macports::ui_prefix bootstrap_options: $bootstrap_option: [set macports::$bootstrap_option]"
+                } else {
+                    lappend mpenv "bootstrap_options $bootstrap_option [set macports::$bootstrap_option]"
+                }
+            }
+        }
+    }
+    if {[info exists macports::sources]} {
+        foreach source $macports::sources {
+            if {![macports::ui_isset ports_quiet]} {
+                lappend mpenv "$macports::ui_prefix port_tree_sources: $source"
+            } else {
+                lappend mpenv "port_tree_sources $source"
+            }
+        }
+    }
+    if {[info exists macports::global_variations]} {
+        set gvl {}
+        foreach {variation mode} [array get macports::global_variations] {
+            lappend gvl $mode$variation
+        }
+        if {![macports::ui_isset ports_quiet]} {
+            lappend mpenv "$macports::ui_prefix global_variations: [join $gvl { }]"
+        } else {
+            lappend mpenv "global_variations [join $gvl { }]"
+        }
+    }
+    ui_msg "[join $mpenv \n]"
+    return 0
+}
+
 # Provided UI instantiations
 # For standard messages, the following priorities are defined
 #     debug, info, msg, warn, error
@@ -697,6 +741,9 @@
                     if {[lsearch -exact $bootstrap_options $option] >= 0} {
                         set macports::$option [string trim $val]
                         global macports::$option
+                        if {[info exists macports::ui_options(ports_env)]} {
+                            ui_msg "$macports::ui_prefix $file: ${option}: [set macports::$option]"
+                        }
                     }
                 }
             }
@@ -713,6 +760,9 @@
                 if {[lsearch -exact $user_options $option] >= 0} {
                     set macports::$option $val
                     global macports::$option
+                    if {[info exists macports::ui_options(ports_env)]} {
+                        ui_msg "$macports::ui_prefix user: ${option}: [set macports::$option]"
+                    }
                 }
             }
         }
@@ -740,6 +790,9 @@
                     }
                 }
                 lappend sources [concat [list $url] $flags]
+                if {[info exists macports::ui_options(ports_env)]} {
+                    ui_msg "$macports::ui_prefix $sources_conf: [lindex $sources end]"
+                }
             } else {
                 ui_warn "$sources_conf specifies invalid source '$line', ignored."
             }
Index: src/port/port.tcl
===================================================================
--- src/port/port.tcl	(revision 135063)
+++ src/port/port.tcl	(working copy)
@@ -2812,6 +2812,12 @@
 }
 
 
+proc action_environment { action portlist opts } {
+    set status [macports::environment]
+    return $status
+}
+
+
 proc action_platform { action portlist opts } {
     if {![macports::ui_isset ports_quiet]} {
         puts -nonewline "Platform: "
@@ -4241,6 +4247,7 @@
     diagnose    [list action_diagnose       [ACTION_ARGS_NONE]] \
     \
     version     [list action_version        [ACTION_ARGS_NONE]] \
+    environment [list action_environment    [ACTION_ARGS_NONE]] \
     platform    [list action_platform       [ACTION_ARGS_NONE]] \
     \
     uninstall   [list action_uninstall      [ACTION_ARGS_PORTS]] \
@@ -4498,6 +4505,9 @@
             set opts [string range $arg 1 end]
             foreach c [split $opts {}] {
                 switch -- $c {
+                    e {
+                        set ui_options(ports_env) yes
+                    }
                     v {
                         set ui_options(ports_verbose) yes
                     }
