threads / patch / 17664

patch, 2 partsgit-web--browse: Fix check for /bin/start

Subject: [PATCH 1/2] git-web--browse: Fix check for /bin/start

## tl;dr

2 messages between Feb 8, 2009 and Feb 8, 2009. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Todd Zullinger· Feb 8, 2009, 23:12 UTC · lore

The previous check in git-web--browse for /bin/start used test -n /bin/start, which was always true. This lead to "start" being tried first in the browser list. On systems with upstart installed, "start" exists and might be in the PATH, but it makes a poor choice for a web browser. Instead, test that /bin/start exists and is executable.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
---

This test is still a bit fragile, as it relies on the start from upstart not being installed in /bin. I don't know if that's something we can count on or not. If not, the test needs to be extended to differentiate between the MingW's start and upstart's start. Does the MingW start have a --version string or something we could check before adding start to the list?

 git-web--browse.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to git-web--browse.sh +1 −1
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 78d236b..7ed0fad 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -115,7 +115,7 @@ if test -z "$browser" ; then
 	browser_candidates="open $browser_candidates"
     fi
     # /bin/start indicates MinGW
-    if test -n /bin/start; then
+    if test -x /bin/start; then
 	browser_candidates="start $browser_candidates"
     fi
-- 
1.6.1.3

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Honesty is the best policy, but insanity is a better defense.
Todd Zullinger· Feb 8, 2009, 23:13 UTC · re: Todd Zullinger · lore

[PATCH 2/2] git-web--browse: Use xdg-open if it is available

Signed-off-by: Todd Zullinger <tmz@pobox.com>
---

For now, I didn't remove any of the KDE specific hacks. It seemed better to add xdg-open and let it prove whether it's workable first.

Is testing for start and xdg-open based on their paths robust enough? Is there a more portable, preferred method to search for these programs in $PATH?

 git-web--browse.sh |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
Show changes to git-web--browse.sh +6 −2
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 7ed0fad..a72cd5b 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -31,7 +31,7 @@ valid_custom_tool()

 valid_tool() {
 	case "$1" in
-		firefox | iceweasel | konqueror | w3m | links | lynx | dillo | open | start)
+		firefox | iceweasel | konqueror | w3m | links | lynx | dillo | open | start | xdg-open)
 			;; # happy
 		*)
 			valid_custom_tool "$1" || return 1
@@ -118,6 +118,10 @@ if test -z "$browser" ; then
     if test -x /bin/start; then
 	browser_candidates="start $browser_candidates"
     fi
+    # Use xdg-open if it is available
+    if test -x /usr/bin/xdg-open; then
+	browser_candidates="xdg-open $browser_candidates"
+    fi

     for i in $browser_candidates; do
 	init_browser_path $i
@@ -161,7 +165,7 @@ case "$browser" in
 		;;
 	esac
 	;;
-    w3m|links|lynx|open|start)
+    w3m|links|lynx|open|start|xdg-open)
 	eval "$browser_path" "$@"
 	;;
     dillo)
-- 
1.6.1.3

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
He may look like an idiot and talk like an idiot but don't let that
fool you. He really is an idiot.
    -- Groucho Marx

← back to recent threads