Skip to contentSkip to conversation

web--browse cleanup and extensions

PATCH In review Giuseppe Bilotta 3 participants 13 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

v3 cover web--browse cleanup and extensions

Differences from the previous revision of this patchset:

* the CodingGuidelines patch was dropped, since it's merged in next
* the chromium support patch had some stylistic changes suggested by Junio
* the *www-browser patch adds support for detecting konqueror and kfmclient, which required some changes to the version string retrieval code; also, readlink is only used if available.

Giuseppe Bilotta (6):
web--browse: coding style
web--browse: split valid_tool list
web--browse: support opera, seamonkey and elinks
web--browse: better support for chromium
web--browse: use *www-browser if available
web--browse: look at the BROWSER env var

 Documentation/git-web--browse.txt |   10 ++
 git-web--browse.sh                |  302 ++++++++++++++++++++++++++-----------
 2 files changed, 225 insertions(+), 87 deletions(-)
Signature · 1 line
1.7.3.2.664.g294b8.dirty
#1 lore raw

PATCH v3 1/6 web--browse: coding style

Retab and deindent choices in case statements.

---
 git-web--browse.sh |  166 ++++++++++++++++++++++++++--------------------------
 1 files changed, 83 insertions(+), 83 deletions(-)
git-web--browse.sh +83 -83
index 3fc4166..7c4568f 100755
@@ -31,11 +31,11 @@ valid_custom_tool()
 
 valid_tool() {
 	case "$1" in
-		firefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)
-			;; # happy
-		*)
-			valid_custom_tool "$1" || return 1
-			;;
+	firefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)
+		;; # happy
+	*)
+		valid_custom_tool "$1" || return 1
+		;;
 	esac
 }
 
@@ -46,139 +46,139 @@ init_browser_path() {
 
 while test $# != 0
 do
-    case "$1" in
+	case "$1" in
 	-b|--browser*|-t|--tool*)
-	    case "$#,$1" in
+		case "$#,$1" in
 		*,*=*)
-		    browser=`expr "z$1" : 'z-[^=]*=\(.*\)'`
-		    ;;
+			browser=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+			;;
 		1,*)
-		    usage ;;
+			usage ;;
 		*)
-		    browser="$2"
-		    shift ;;
-	    esac
-	    ;;
+			browser="$2"
+			shift ;;
+		esac
+		;;
 	-c|--config*)
-	    case "$#,$1" in
+		case "$#,$1" in
 		*,*=*)
-		    conf=`expr "z$1" : 'z-[^=]*=\(.*\)'`
-		    ;;
+			conf=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+			;;
 		1,*)
-		    usage ;;
+			usage ;;
 		*)
-		    conf="$2"
-		    shift ;;
-	    esac
-	    ;;
+			conf="$2"
+			shift ;;
+		esac
+		;;
 	--)
-	    break
-	    ;;
+		break
+		;;
 	-*)
-	    usage
-	    ;;
+		usage
+		;;
 	*)
-	    break
-	    ;;
-    esac
-    shift
+		break
+		;;
+	esac
+	shift
 done
 
 test $# = 0 && usage
 
 if test -z "$browser"
 then
-    for opt in "$conf" "web.browser"
-    do
-	test -z "$opt" && continue
-	browser="`git config $opt`"
-	test -z "$browser" || break
-    done
-    if test -n "$browser" && ! valid_tool "$browser"; then
-	echo >&2 "git config option $opt set to unknown browser: $browser"
-	echo >&2 "Resetting to default..."
-	unset browser
-    fi
+	for opt in "$conf" "web.browser"
+	do
+		test -z "$opt" && continue
+		browser="`git config $opt`"
+		test -z "$browser" || break
+	done
+	if test -n "$browser" && ! valid_tool "$browser"; then
+		echo >&2 "git config option $opt set to unknown browser: $browser"
+		echo >&2 "Resetting to default..."
+		unset browser
+	fi
 fi
 
 if test -z "$browser" ; then
-    if test -n "$DISPLAY"; then
-	browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo"
-	if test "$KDE_FULL_SESSION" = "true"; then
-	    browser_candidates="konqueror $browser_candidates"
+	if test -n "$DISPLAY"; then
+		browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo"
+		if test "$KDE_FULL_SESSION" = "true"; then
+			browser_candidates="konqueror $browser_candidates"
+		fi
+	else
+		browser_candidates="w3m links lynx"
 	fi
-    else
-	browser_candidates="w3m links lynx"
-    fi
-    # SECURITYSESSIONID indicates an OS X GUI login session
-    if test -n "$SECURITYSESSIONID" \
-	    -o "$TERM_PROGRAM" = "Apple_Terminal" ; then
-	browser_candidates="open $browser_candidates"
-    fi
-    # /bin/start indicates MinGW
-    if test -x /bin/start; then
-	browser_candidates="start $browser_candidates"
-    fi
-
-    for i in $browser_candidates; do
-	init_browser_path $i
-	if type "$browser_path" > /dev/null 2>&1; then
-	    browser=$i
-	    break
+	# SECURITYSESSIONID indicates an OS X GUI login session
+	if test -n "$SECURITYSESSIONID" \
+		-o "$TERM_PROGRAM" = "Apple_Terminal" ; then
+		browser_candidates="open $browser_candidates"
 	fi
-    done
-    test -z "$browser" && die "No known browser available."
+	# /bin/start indicates MinGW
+	if test -x /bin/start; then
+		browser_candidates="start $browser_candidates"
+	fi
+
+	for i in $browser_candidates; do
+		init_browser_path $i
+		if type "$browser_path" > /dev/null 2>&1; then
+			browser=$i
+			break
+		fi
+	done
+	test -z "$browser" && die "No known browser available."
 else
-    valid_tool "$browser" || die "Unknown browser '$browser'."
+	valid_tool "$browser" || die "Unknown browser '$browser'."
 
-    init_browser_path "$browser"
+	init_browser_path "$browser"
 
-    if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then
-	die "The browser $browser is not available as '$browser_path'."
-    fi
+	if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then
+		die "The browser $browser is not available as '$browser_path'."
+	fi
 fi
 
 case "$browser" in
-    firefox|iceweasel)
+firefox|iceweasel)
 	# Check version because firefox < 2.0 does not support "-new-tab".
 	vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
 	NEWTAB='-new-tab'
 	test "$vers" -lt 2 && NEWTAB=''
 	"$browser_path" $NEWTAB "$@" &
 	;;
-    google-chrome|chrome|chromium)
+google-chrome|chrome|chromium)
 	# Actual command for chromium is chromium-browser.
 	# No need to specify newTab. It's default in chromium
 	eval "$browser_path" "$@" &
 	;;
-    konqueror)
+konqueror)
 	case "$(basename "$browser_path")" in
-	    konqueror)
+	konqueror)
 		# It's simpler to use kfmclient to open a new tab in konqueror.
 		browser_path="$(echo "$browser_path" | sed -e 's/konqueror$/kfmclient/')"
 		type "$browser_path" > /dev/null 2>&1 || die "No '$browser_path' found."
 		eval "$browser_path" newTab "$@"
 		;;
-	    kfmclient)
+	kfmclient)
 		eval "$browser_path" newTab "$@"
 		;;
-	    *)
+	*)
 		"$browser_path" "$@" &
 		;;
 	esac
 	;;
-    w3m|links|lynx|open)
+w3m|links|lynx|open)
 	eval "$browser_path" "$@"
 	;;
-    start)
-        exec "$browser_path" '"web-browse"' "$@"
-        ;;
-    dillo)
+start)
+	exec "$browser_path" '"web-browse"' "$@"
+	;;
+dillo)
 	"$browser_path" "$@" &
 	;;
-    *)
+*)
 	if test -n "$browser_cmd"; then
-	    ( eval $browser_cmd "$@" )
+		( eval $browser_cmd "$@" )
 	fi
 	;;
 esac
Signature · 1 line
1.7.3.2.664.g294b8.dirty
#2 lore raw

PATCH v3 2/6 web--browse: split valid_tool list

In reply to Giuseppe Bilotta

It was getting too long, and we want to add some more.

---
 git-web--browse.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
git-web--browse.sh +2 -1
index 7c4568f..e48e30d 100755
@@ -31,7 +31,8 @@ valid_custom_tool()
 
 valid_tool() {
 	case "$1" in
-	firefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)
+	firefox | iceweasel | chrome | google-chrome | chromium |\
+	konqueror | w3m | links | lynx | dillo | open | start)
 		;; # happy
 	*)
 		valid_custom_tool "$1" || return 1
Signature · 1 line
1.7.3.2.664.g294b8.dirty
#3 lore raw

PATCH v3 3/6 web--browse: support opera, seamonkey and elinks

In reply to Giuseppe Bilotta

The list of supported browsers is also updated in the documentation.

---
 Documentation/git-web--browse.txt |    6 ++++++
 git-web--browse.sh                |   14 +++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
Documentation/git-web--browse.txt +6 -0
index 51e8e0a..5d3ae07 100644
@@ -20,8 +20,14 @@ The following browsers (or commands) are currently supported:
 
 * firefox (this is the default under X Window when not using KDE)
 * iceweasel
+* seamonkey
+* iceape
+* chromium
+* google-chrome
 * konqueror (this is the default under KDE, see 'Note about konqueror' below)
+* opera
 * w3m (this is the default outside graphical environments)
+* elinks
 * links
 * lynx
 * dillo
git-web--browse.sh +7 -7
index e48e30d..48e5a28 100755
@@ -31,8 +31,8 @@ valid_custom_tool()
 
 valid_tool() {
 	case "$1" in
-	firefox | iceweasel | chrome | google-chrome | chromium |\
-	konqueror | w3m | links | lynx | dillo | open | start)
+	firefox | iceweasel | seamonkey | iceape | chrome | google-chrome | chromium |\
+	konqueror | opera | w3m | elinks | links | lynx | dillo | open | start)
 		;; # happy
 	*)
 		valid_custom_tool "$1" || return 1
@@ -104,12 +104,12 @@ fi
 
 if test -z "$browser" ; then
 	if test -n "$DISPLAY"; then
-		browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo"
+		browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror opera seamonkey iceape w3m elinks links lynx dillo"
 		if test "$KDE_FULL_SESSION" = "true"; then
 			browser_candidates="konqueror $browser_candidates"
 		fi
 	else
-		browser_candidates="w3m links lynx"
+		browser_candidates="w3m elinks links lynx"
 	fi
 	# SECURITYSESSIONID indicates an OS X GUI login session
 	if test -n "$SECURITYSESSIONID" \
@@ -140,7 +140,7 @@ else
 fi
 
 case "$browser" in
-firefox|iceweasel)
+firefox|iceweasel|seamonkey|iceape)
 	# Check version because firefox < 2.0 does not support "-new-tab".
 	vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
 	NEWTAB='-new-tab'
@@ -168,13 +168,13 @@ konqueror)
 		;;
 	esac
 	;;
-w3m|links|lynx|open)
+w3m|elinks|links|lynx|open)
 	eval "$browser_path" "$@"
 	;;
 start)
 	exec "$browser_path" '"web-browse"' "$@"
 	;;
-dillo)
+opera|dillo)
 	"$browser_path" "$@" &
 	;;
 *)
Signature · 1 line
1.7.3.2.664.g294b8.dirty
#4 lore raw

PATCH v3 4/6 web--browse: better support for chromium

In reply to Giuseppe Bilotta

On Debian-based distributions, Chromium the browser is available under the name chromium-browser rather than chromium, to prevent conflicts with the Chromium B.S.U. game.

Look for chromium-browser first when setting the path for chromium, and also add chromium-browser as a supported browser name. Document the dual-name support, and mention the dual-name support for (google-)chrome too.

---
 Documentation/git-web--browse.txt |    4 ++--
 git-web--browse.sh                |   12 ++++++++----
 2 files changed, 10 insertions(+), 6 deletions(-)
Documentation/git-web--browse.txt +2 -2
index 5d3ae07..c0416e5 100644
@@ -22,8 +22,8 @@ The following browsers (or commands) are currently supported:
 * iceweasel
 * seamonkey
 * iceape
-* chromium
-* google-chrome
+* chromium (also supported as chromium-browser)
+* google-chrome (also supported as chrome)
 * konqueror (this is the default under KDE, see 'Note about konqueror' below)
 * opera
 * w3m (this is the default outside graphical environments)
git-web--browse.sh +8 -4
index 48e5a28..b2fc3b4 100755
@@ -31,7 +31,8 @@ valid_custom_tool()
 
 valid_tool() {
 	case "$1" in
-	firefox | iceweasel | seamonkey | iceape | chrome | google-chrome | chromium |\
+	firefox | iceweasel | seamonkey | iceape |\
+	chrome | google-chrome | chromium | chromium-browser |\
 	konqueror | opera | w3m | elinks | links | lynx | dillo | open | start)
 		;; # happy
 	*)
@@ -42,6 +43,10 @@ valid_tool() {
 
 init_browser_path() {
 	browser_path=$(git config "browser.$1.path")
+	if test -z "$browser_path" -a "$1" = chromium &&
+	   type chromium-browser > /dev/null 2>&1 ; then
+		browser_path=chromium-browser
+	fi
 	test -z "$browser_path" && browser_path="$1"
 }
 
@@ -104,7 +109,7 @@ fi
 
 if test -z "$browser" ; then
 	if test -n "$DISPLAY"; then
-		browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror opera seamonkey iceape w3m elinks links lynx dillo"
+		browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo"
 		if test "$KDE_FULL_SESSION" = "true"; then
 			browser_candidates="konqueror $browser_candidates"
 		fi
@@ -147,8 +152,7 @@ firefox|iceweasel|seamonkey|iceape)
 	test "$vers" -lt 2 && NEWTAB=''
 	"$browser_path" $NEWTAB "$@" &
 	;;
-google-chrome|chrome|chromium)
-	# Actual command for chromium is chromium-browser.
+google-chrome|chrome|chromium|chromium-browser)
 	# No need to specify newTab. It's default in chromium
 	eval "$browser_path" "$@" &
 	;;
Signature · 1 line
1.7.3.2.664.g294b8.dirty
#7 lore raw

PATCH v3 5/6 web--browse: use *www-browser if available

In reply to Giuseppe Bilotta

Debian and derivatives have an alternatives-based default browser configuration that uses the /usr/bin/gnome-www-browser, /usr/bin/x-www-browser and /usr/bin/www-browser symlinks.

When no browser is selected by the user and the Debian alternatives are available, try to see if they are one of our recognized selection and in the affermative case use it. Otherwise, warn the user about them being unsupported and move on with the previous detection logic.

---
 Documentation/git-web--browse.txt |    4 ++
 git-web--browse.sh                |   84 +++++++++++++++++++++++++++++++++++-
 2 files changed, 85 insertions(+), 3 deletions(-)
Documentation/git-web--browse.txt +4 -0
index c0416e5..157738a 100644
@@ -36,6 +36,10 @@ The following browsers (or commands) are currently supported:
 
 Custom commands may also be specified.
 
+If no default browser is specified, and /usr/bin/gnome-www-browser
+(under GNOME), /usr/bin/x-www-browser (under X) or /usr/bin/www-browser
+is present, they are used to determine the browser to use.
+
 OPTIONS
 -------
 -b <browser>::
git-web--browse.sh +81 -3

112 lines not on this page · raw message

Signature · 1 line
1.7.3.2.664.g294b8.dirty
#10 lore raw

PATCH v3 6/6 web--browse: look at the BROWSER env var

In reply to Giuseppe Bilotta

The BROWSER environment variables is used in Debian-based systems to set the user-preferred browser(s).

It contains a colon-separate list of commands to (try to) execute to open a web page. Each item in the list is allowed to have a %s placeholder to be replaced by the URL, in which case we try to run the command as is. If no placeholder is found, we only look at the command name to see if it matches one of our known browsers.

---
 git-web--browse.sh |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
git-web--browse.sh +45 -0
index b496b6c..da36ca4 100755
@@ -164,6 +164,51 @@ then
 	fi
 fi
 
+# Debian and derivatives provide a sensible-brower script that tries to
+# invoke the user or system preferred browser most appropriate for the
+# current situation (X or no X, GNOME or other/no DE).
+# We do not use the sensible-browser script directly since it doesn't
+# allow us to open pages in a new tab, but we can use the underlying
+# infrastructure to find the browser to use if the user didn't choose
+# one. This is done by looking at the BROWSER environment variable
+# first, and at the *www-browser links if the first search is
+# unsuccesful.
+
+# The BROWSER environment variable is a colon-separate list of commands
+# to (try and) execute to launch the browser. sensible-browser allows
+# each BROWSER entry to contain a %s placeholder that will be replaced
+# by the URL to be opened.
+# If an entry contains a %s we run it as-is, without doing any detection, on
+# the premise that it represents the exact way the user expects the browser to
+# be called. If the execution fails, we do not bail out, since the
+# failure might be due to the entry being for a graphical browser and
+# the GUI not being available, which is the reason why multiple entries
+# can be specified in BROWSER in the first place.
+# An entry without a %s is only taken as indication of the preferred
+# browser, so we proceed with our usual detection logic.
+if test -z "$browser" -a -n "$BROWSER"; then
+	OLDIFS="$IFS"
+	IFS=:
+	for i in $BROWSER; do
+		case "$i" in
+			*sensible-browser*)
+				;; # skip
+			*%s*)
+				IFS="$OLDIFS"
+				cmd=$(printf "$i\n" "$*")
+				$cmd && exit 0
+				;;
+			*)
+				prog=$(which "$i" 2> /dev/null)
+				if test -n "$prog" -a -x "$prog" && valid_browser_executable "$prog" ; then
+					break
+				fi
+				;;
+		esac
+	done
+	IFS="$OLDIFS"
+fi
+
 # Debian and derivatives use gnome-www-browser, x-www-browser or www-browser to
 # set the default browser for the system. If the user did not specify a tool and
 # we detect that one of the *www-browser links to a supported one, we pick it.
Signature · 1 line
1.7.3.2.664.g294b8.dirty
#11 lore raw

Re: [PATCHv3 6/6] web--browse: look at the BROWSER env var

Quoted 2 lines · Giuseppe Bilotta

The BROWSER environment variables is used in Debian-based systems to set the user-preferred browser(s).

I _thought_ BROWSER was not Debian-specific, but I cannot find any evidence of that online. See:

http://www.catb.org/~esr/BROWSER/
http://www.dwheeler.com/browse/secure_browser.html

At least xdg-open implements a variant on it, and I had assumed apps preceding xdg-utils did, too.

#12 lore raw

Re: [PATCHv3 6/6] web--browse: look at the BROWSER env var

Quoted 5 lines · Jonathan Nieder
Quoted 2 lines · Giuseppe Bilotta

The BROWSER environment variables is used in Debian-based systems to set the user-preferred browser(s).

Quoted 8 lines

I _thought_ BROWSER was not Debian-specific, but I cannot find any evidence of that online.  See:

 http://www.catb.org/~esr/BROWSER/
 http://www.dwheeler.com/browse/secure_browser.html

At least xdg-open implements a variant on it, and I had assumed apps preceding xdg-utils did, too.

IIRC, RedHat's sensible-browser equivalent, htmlview, used to use BROWSER. The package is now obsolete, though, and I'm not even sure it used BROWSER at all in its latest incarnations.

xdg-open _does_ use BROWSER though. So maybe I should clear the Debian-specificity of this patch.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#6 lore raw

Re: [PATCHv3 4/6] web--browse: better support for chromium

Quoted 2 lines · Junio C Hamano

Up to this point of the series, I think v3 is a regression compared to what is queued on 'pu'.

Ouch. Including or excluding this one? (Unless I did a mistake, the only difference here was the merging of the conditionals when path-checking chromium)

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#8 lore raw

Re: [PATCHv3 5/6] web--browse: use *www-browser if available

In reply to Giuseppe Bilotta

git-web--browse.sh init_browser_path() { · line 77

Quoted 9 lines · Giuseppe Bilotta
git-web--browse.sh +9 -0
+	# if the linked executable doesn't match a browser name we know about,
+	# look at the version string
+
+	# even though most browsers (and applications, in fact) will show their
+	# name and version on the first line of the --version output, this is
+	# not true in particular for the KDE apps (e.g. konqueror and kfmclient),
+	# which display their name and version on the LAST line. So we cannot
+	# clip the version string at the first line when retrieving it. Rather,
+	# we keep it whole and then limit it when we know what we're dealing with.

I'd be more worried about the ones that do not understand --version and spawn a new window.

git-web--browse.sh init_browser_path() { · line 82

Quoted 4 lines
git-web--browse.sh +4 -0
+	verstring="$("$testexe" --version 2> /dev/null)"
+	browser="$(echo "$verstring" | head -n 1 | cut -f1 -d' ' | tr A-Z a-z)"
+	case "$browser" in
+		mozilla)

What was the first patch in this series about again ;-)?

Quoted 16 lines
git-web--browse.sh +16 -0
+			verstring="$(echo "$verstring" | head -n 1)"
+			browser="$(echo "$verstring" | cut -f2 -d' ' | tr A-Z a-z)"
+			;;
+		google)
+			verstring="$(echo "$verstring" | head -n 1)"
+			browser="google-chrome"
+			;;
+		qt:)
+			# konqueror, kfmclient or other KDE app
+			verstring="$(echo "$verstring" | tail -n 1)"
+			browser="$(echo "$verstring" | cut -f1 -d:)"
+			;;
+		*)
+			verstring="$(echo "$verstring" | head -n 1)"
+			;;
+

git-web--browse.sh init_browser_path() { · line 108

Quoted 10 lines
git-web--browse.sh +10 -0
+	esac
+	if valid_tool "$browser" ; then
+		browser_path="$i"
+		return 0
+	fi
+
+	echo >&2 "$testexe (detected as $browser) is not a supported browser, skipping"
+	browser=""
+	return 1
+}

Sorry, but I simply do not think it is worth this ugliness to get slight customization between -new-tab, newTab, and nothingness.

#9 lore raw

Re: [PATCHv3 5/6] web--browse: use *www-browser if available

Quoted 12 lines · Junio C Hamano
Quoted 9 lines · Giuseppe Bilotta

+     # if the linked executable doesn't match a browser name we know about,
+     # look at the version string
+
+     # even though most browsers (and applications, in fact) will show their
+     # name and version on the first line of the --version output, this is
+     # not true in particular for the KDE apps (e.g. konqueror and kfmclient),
+     # which display their name and version on the LAST line. So we cannot
+     # clip the version string at the first line when retrieving it. Rather,
+     # we keep it whole and then limit it when we know what we're dealing with.

Quoted 2 lines

I'd be more worried about the ones that do not understand --version and spawn a new window.

That's indeed a potential issue (although I _do_ wonder if there are browsers that act like that; the only one I couldn't try, on Linux, was dillo).

Quoted 6 lines
Quoted 4 lines

+     verstring="$("$testexe" --version 2> /dev/null)"
+     browser="$(echo "$verstring" | head -n 1 | cut -f1 -d' ' | tr A-Z a-z)"
+     case "$browser" in
+             mozilla)

What was the first patch in this series about again ;-)?

Oh my! LOL. Ok, I can fix that 8-D

Quoted 21 lines
Quoted 21 lines

+                     verstring="$(echo "$verstring" | head -n 1)"
+                     browser="$(echo "$verstring" | cut -f2 -d' ' | tr A-Z a-z)"
+                     ;;
+             google)
+                     verstring="$(echo "$verstring" | head -n 1)"
+                     browser="google-chrome"
+                     ;;
+             qt:)
+                     # konqueror, kfmclient or other KDE app
+                     verstring="$(echo "$verstring" | tail -n 1)"
+                     browser="$(echo "$verstring" | cut -f1 -d:)"
+                     ;;
+             *)
+                     verstring="$(echo "$verstring" | head -n 1)"
+                     ;;
+
+     esac
+     if valid_tool "$browser" ; then
+             browser_path="$i"
+             return 0
+     fi

Quoted 8 lines

git-web--browse.sh init_browser_path() { · line 108

Quoted 5 lines
git-web--browse.sh +5 -0
+
+     echo >&2 "$testexe (detected as $browser) is not a supported browser, skipping"
+     browser=""
+     return 1
+}

Sorry, but I simply do not think it is worth this ugliness to get slight customization between -new-tab, newTab, and nothingness.

I personally don't have a particular feeling for forcing the opening in a new tab (and I might have over-engineered it, although it's not really much more complex than the previous versions of this patchset, it's just refactored.

If this requirement is relaxed, the patch becomes much simpler, and we can include direct support for xdg-open, sensible-browser, htlmview & so forth.

Signature · 1 line
Giuseppe "Oblomov" Bilotta