Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove actions that make no sense on command line #29

Closed

Conversation

kurthindenburg
Copy link
Contributor

Remove cd, quit, exit from command line actions

closes https://trac.macports.org/ticket/32866

@jmroot
Copy link
Member

jmroot commented Jul 29, 2017

This will run every time find_action is called, and modifies the global action_array which is used in other places like print_help. I would do it like this instead:

diff --git a/src/port/port.tcl b/src/port/port.tcl
index a70c975d..8a1494d7 100755
--- a/src/port/port.tcl
+++ b/src/port/port.tcl
@@ -4371,7 +4371,17 @@ proc find_action { action } {
     global action_array
 
     if {![info exists action_array($action)]} {
-        return [array names action_array [string tolower $action]*]
+        # list of actions that are valid for this mode
+        global action_list
+        if {![info exists action_list]} {
+            global ui_options
+            if {![info exists ui_options(ports_commandfiles)]} {
+                set action_list [lsearch -regexp -all -inline -not [array names action_array] {^quit$|^exit$|^cd$}]
+            } else {
+                set action_list [array names action_array]
+            }
+        }
+        return [lsearch -glob -inline -all $action_list [string tolower $action]*]
     }
 
     return $action

@raimue
Copy link
Member

raimue commented Jul 29, 2017

I think it would make more sense to have a flag in action_array for that instead of hardcoding the names somewhere else.

@jmroot
Copy link
Member

jmroot commented Jul 30, 2017

Fair point, though storing the information as a flag in action_array may make it more complicated to extract the action names we want. Would a shellmode_action_list defined next to action_array be an acceptable compromise?

@jmroot jmroot closed this in 33fa555 Aug 24, 2017
kurthindenburg pushed a commit to kurthindenburg/macports-base that referenced this pull request Aug 25, 2017
The cd, quit and exit actions are only useful in shell/batch mode. So, ignore
them when considering what an abbreviated action could expand to, when not in
that mode.

Closes: macports#29
Closes: https://trac.macports.org/ticket/32866
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants