[kupfer] commands: Recognize absolute paths with arguments



commit 0003b6e237b8a31ab525d6352c894c62e0a6e2ca
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sat Apr 9 01:39:21 2011 +0200

    commands: Recognize absolute paths with arguments
    
    Absolute paths with arguments, such as "/bin/grep --help" were not
    handled by any part of kupfer. Now the commands module will make sure
    it's a command.
    
    Launchpad-ref: https://answers.launchpad.net/kupfer/+question/152093

 kupfer/plugin/commands.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/commands.py b/kupfer/plugin/commands.py
index de0df77..6e6e908 100644
--- a/kupfer/plugin/commands.py
+++ b/kupfer/plugin/commands.py
@@ -194,11 +194,16 @@ class CommandTextSource (TextSource):
 			return
 		if len(text.splitlines()) > 1:
 			return
-		firstword = text.split()[0]
-		if firstword.startswith("/"):
+		## check for absolute path with arguments
+		firstwords = text.split()
+		## files are handled elsewhere
+		if firstwords[0].startswith("/") and len(firstwords) == 1:
 			return
+		## absolute paths come out here since
+		## os.path.join with two abspaths returns the latter
+		firstword = firstwords[0]
 		# iterate over $PATH directories
-		PATH = os.environ.get("PATH") or os.defpath
+		PATH = os.environ.get("PATH", os.defpath)
 		for execdir in PATH.split(os.pathsep):
 			exepath = os.path.join(execdir, firstword)
 			# use filesystem encoding here



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]