diff --git a/twander.py b/twander.py index 621aebd..87597fc 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.0 2003/02/17 20:38:07 tundra Exp $" +RCSID = "$Id: twander.py,v 3.1 2003/02/23 22:17:00 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -1464,7 +1464,7 @@ ### # Bind handler for "Run Command" - self.DirList.bind(self.KeyBindings["RUNCMD"], KeyRunCommand) + self.DirList.bind(self.KeyBindings["RUNCMD"], lambda event : KeyRunCommand(event, DoCmdShell=True)) # Bind handler for "Item Select" self.DirList.bind(self.KeyBindings["SELKEY"], DirListHandler) @@ -2150,23 +2150,20 @@ # Event Handler: Run Manually Entered Command #### -def KeyRunCommand(event, initial=""): +def KeyRunCommand(event, initial="", DoCmdShell=False): global UI + # NOTE: DoCmdShell determines whether or not we do CMDSHELL + # processing (if enabled). It is *off* by default because + # we do not want commands invoked via the command history + # mechanism to use this feature - doing so would cause + # cascading of the CMDSHELL string on each subsequent + # invocation. So, the only time we want to do CMDSHELL + # processing is when the user presses the RUNCMD key. + # The binding for this key thus sets DoCmdShell to True. + # Prompt with passed initial edit string if initial: - - # This feature is invoked with an initial string when we - # are playing back something from the command history. - # If the CMDSHELL feature is enabled, we need to insure - # that we do not prepend that string multiple times as - # the command is reinvoked. We do that by removing that - # prepended string from the passed initial string. - # We also want to remove the previously added single quotes. - - if (CMDSHELL != NOCMDSHELL) and initial.startswith(CMDSHELL): - initial = initial[len(CMDSHELL)+2:-1] - cmd = askstring(pRUNCMD, pENCMD, initialvalue=initial) # Prompt with last manually entered command @@ -2180,10 +2177,10 @@ # Execute command (if any) - Blank entry means do nothing/return if cmd: - # Prepend the + # Do CMDSHELL Processing if enabled and requested mycmd = cmd - if CMDSHELL != NOCMDSHELL: # See if feature is enabled + if CMDSHELL != NOCMDSHELL and DoCmdShell: # See if feature is enabled and requested if not mycmd.startswith('\\'): # See if user is trying to escape the feature mycmd = "%s '%s'" % (CMDSHELL, cmd)