threads / discuss / 25938

[PATCHv2 0/7] web--browse cleanup and extensions

Subject: [PATCHv2 0/7] web--browse cleanup and extensions

## tl;dr

25 messages between Dec 3, 2010 and Dec 7, 2010.

replies: 24people: 4as markdown or json

Giuseppe Bilotta· Dec 3, 2010, 16:47 UTC · lore

This second issue of the web--browse cleanup and extension patchset has seen some stylistic changes in the first patches as discussed on the ML, and a new patch to add support for the BROWSER env var. Support for xdg-open is still missing, due to the lack of an obvious way to suggest opening pages in new tabs (same reason why we don't directly support Debian's sensible-browser).

I'm quite convinced that the first 4 patches (up to the "support opera, seamonkey and elinks" patch, inclusive) are ready for merging.

The fifth patch is slightly more extensive than in the previous iteration, including chromium-browser as a supported option, but still looking for chromium-browser first even when browser=chromium.

The last two patches are more RFCish. I tried to include the changes suggested by Christian, unless of course I forgot something. Suggestions on possible ways to improve the proposed approach are welcome.

Giuseppe Bilotta (7):
  CodingGuidelines: mention whitespace preferences for shell scripts
  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 (x-)www-browser if available
  web--browse: look at the BROWSER env var
 Documentation/CodingGuidelines    |    4 +
 Documentation/git-web--browse.txt |   10 ++
 git-web--browse.sh                |  276 +++++++++++++++++++++++++------------
 3 files changed, 203 insertions(+), 87 deletions(-)
-- 
1.7.3.2.664.g294b8.dirty
Giuseppe Bilotta· Dec 3, 2010, 16:47 UTC · re: Giuseppe Bilotta · lore

[PATCHv2 1/7] CodingGuidelines: mention whitespace preferences for shell scripts

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 Documentation/CodingGuidelines |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 5aa2d34..a9191d0 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -31,6 +31,10 @@ But if you must have a list of rules, here they are.
 
 For shell scripts specifically (not exhaustive):
 
+ - We use tabs for indentation.
+
+ - Case arms are not indented with respect to the case and esac lines.
+
  - We prefer $( ... ) for command substitution; unlike ``, it
    properly nests.  It should have been the way Bourne spelled
    it from day one, but unfortunately isn't.
-- 
1.7.3.2.664.g294b8.dirty
Junio C Hamano· Dec 3, 2010, 21:43 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2 1/7] CodingGuidelines: mention whitespace preferences for shell scripts

Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
Show 16 quoted lines
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
> ---
>  Documentation/CodingGuidelines |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index 5aa2d34..a9191d0 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -31,6 +31,10 @@ But if you must have a list of rules, here they are.
>  
>  For shell scripts specifically (not exhaustive):
>  
> + - We use tabs for indentation.
> +
> + - Case arms are not indented with respect to the case and esac lines.

Thanks. I am tempted to rephrase the latter as:

    Case arms are indented at the same depth as case and esac lines.
It makes it less hard to read and understand without negation.
Giuseppe Bilotta· Dec 3, 2010, 22:02 UTC · re: Junio C Hamano · lore

Re: [PATCHv2 1/7] CodingGuidelines: mention whitespace preferences for shell scripts

On Fri, Dec 3, 2010 at 10:43 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 25 quoted lines
> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
>
>> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
>> ---
>>  Documentation/CodingGuidelines |    4 ++++
>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>
>> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
>> index 5aa2d34..a9191d0 100644
>> --- a/Documentation/CodingGuidelines
>> +++ b/Documentation/CodingGuidelines
>> @@ -31,6 +31,10 @@ But if you must have a list of rules, here they are.
>>
>>  For shell scripts specifically (not exhaustive):
>>
>> + - We use tabs for indentation.
>> +
>> + - Case arms are not indented with respect to the case and esac lines.
>
> Thanks.
> I am tempted to rephrase the latter as:
>
>    Case arms are indented at the same depth as case and esac lines.
>
> It makes it less hard to read and understand without negation.

Good idea. I'll rephrase in that sense and add a couple more entries about the | spacing and long case arm splitting, for the next rehash of the series.

-- 
Giuseppe "Oblomov" Bilotta
Junio C Hamano· Dec 3, 2010, 22:28 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2 1/7] CodingGuidelines: mention whitespace preferences for shell scripts

Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
> Good idea. I'll rephrase in that sense and add a couple more entries
> about the | spacing and long case arm splitting, for the next rehash
> of the series.

Hm, I don't think there needs a rehash of the whole thing. This one is ready for 'maint' with the rewording), and 2-4 looked Ok.

Giuseppe Bilotta· Dec 3, 2010, 22:46 UTC · re: Junio C Hamano · lore

Re: [PATCHv2 1/7] CodingGuidelines: mention whitespace preferences for shell scripts

On Fri, Dec 3, 2010 at 11:28 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
>
>> Good idea. I'll rephrase in that sense and add a couple more entries
>> about the | spacing and long case arm splitting, for the next rehash
>> of the series.
>
> Hm, I don't think there needs a rehash of the whole thing.  This one is
> ready for 'maint' with the rewording), and 2-4 looked Ok.
Ok then. Do you still want the two extra entries or are they superfluous too?
-- 
Giuseppe "Oblomov" Bilotta
Giuseppe Bilotta· Dec 3, 2010, 16:47 UTC · re: Giuseppe Bilotta · lore

[PATCHv2 2/7] web--browse: coding style

Retab and deindent choices in case statements.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-web--browse.sh |  166 ++++++++++++++++++++++++++--------------------------
 1 files changed, 83 insertions(+), 83 deletions(-)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 3fc4166..7c4568f 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -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
-- 
1.7.3.2.664.g294b8.dirty
Giuseppe Bilotta· Dec 3, 2010, 16:47 UTC · re: Giuseppe Bilotta · lore

[PATCHv2 3/7] web--browse: split valid_tool list

It was getting too long, and we want to add some more.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-web--browse.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 7c4568f..e48e30d 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -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
-- 
1.7.3.2.664.g294b8.dirty
Giuseppe Bilotta· Dec 3, 2010, 16:47 UTC · re: Giuseppe Bilotta · lore

[PATCHv2 4/7] web--browse: support opera, seamonkey and elinks

The list of supported browsers is also updated in the documentation.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 Documentation/git-web--browse.txt |    6 ++++++
 git-web--browse.sh                |   14 +++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index 51e8e0a..5d3ae07 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -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
diff --git a/git-web--browse.sh b/git-web--browse.sh
index e48e30d..48e5a28 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -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" "$@" &
 	;;
 *)
-- 
1.7.3.2.664.g294b8.dirty
Junio C Hamano· Dec 3, 2010, 22:01 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2 4/7] web--browse: support opera, seamonkey and elinks

Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
Show 11 quoted lines
> -w3m|links|lynx|open)
> +w3m|elinks|links|lynx|open)
>  	eval "$browser_path" "$@"
>  	;;
>  start)
>  	exec "$browser_path" '"web-browse"' "$@"
>  	;;
> -dillo)
> +opera|dillo)
>  	"$browser_path" "$@" &
>  	;;

Not a complaint on your patch, but is there a reason we say "eval", "exec" and "(nothing)" in these three case arms?

The above makes the interpretation of $browser_path and $@ inconsistent between lynx family codepath (which would apply $IFS to find the browser) and dillo and start family codepath (which would not), and I am wondering if that difference is intended.

Giuseppe Bilotta· Dec 3, 2010, 22:22 UTC · re: Junio C Hamano · lore

Re: [PATCHv2 4/7] web--browse: support opera, seamonkey and elinks

On Fri, Dec 3, 2010 at 11:01 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
>
>> -w3m|links|lynx|open)
>> +w3m|elinks|links|lynx|open)
>>       eval "$browser_path" "$@"
>>       ;;
>>  start)
>>       exec "$browser_path" '"web-browse"' "$@"
>>       ;;
>> -dillo)
>> +opera|dillo)
>>       "$browser_path" "$@" &
>>       ;;
>
> Not a complaint on your patch, but is there a reason we say "eval", "exec"
> and "(nothing)" in these three case arms?
>
> The above makes the interpretation of $browser_path and $@ inconsistent
> between lynx family codepath (which would apply $IFS to find the browser)
> and dillo and start family codepath (which would not), and I am wondering
> if that difference is intended.

I was wondering about this myself, but since I couldn't come up with an explanation I opted for leaving things as they were. Lacking an explanation I can also provide a patch to standardize invocation.

-- 
Giuseppe "Oblomov" Bilotta
Giuseppe Bilotta· Dec 3, 2010, 16:47 UTC · re: Giuseppe Bilotta · lore

[PATCHv2 5/7] web--browse: better support for chromium

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.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 Documentation/git-web--browse.txt |    4 ++--
 git-web--browse.sh                |   11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index 5d3ae07..c0416e5 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -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)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 48e5a28..d0e99f5 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -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,9 @@ valid_tool() {
 
 init_browser_path() {
 	browser_path=$(git config "browser.$1.path")
+	if test -z "$browser_path" -a "$1" = chromium ; then
+		type chromium-browser > /dev/null 2>&1 && browser_path=chromium-browser
+	fi
 	test -z "$browser_path" && browser_path="$1"
 }
 
@@ -104,7 +108,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 +151,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" "$@" &
 	;;
-- 
1.7.3.2.664.g294b8.dirty
Junio C Hamano· Dec 3, 2010, 21:57 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2 5/7] web--browse: better support for chromium

Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
Show 6 quoted lines
>  init_browser_path() {
>  	browser_path=$(git config "browser.$1.path")
> +	if test -z "$browser_path" -a "$1" = chromium ; then
> +		type chromium-browser > /dev/null 2>&1 && browser_path=chromium-browser
> +	fi
>  	test -z "$browser_path" && browser_path="$1"
We tolerate
	test && test && effect
and even encourage when the construct is short enough, over
	if test && test
        then
        	effect
	fi

But because you are writing an "if" block anyway, I think the above should be like this:

	if test -z "$browser_path" &&
           test "$1" = chromium &&
           type chromium-browser >/dev/null 2>&1
	then
        	browser_path=chromium-browser
	fi
	browser_path=${browser_path:-"$1"}
Yours is:
	if test && test
        then
        	test && effect
	fi
which is less than readable, no?
Giuseppe Bilotta· Dec 3, 2010, 22:25 UTC · re: Junio C Hamano · lore

Re: [PATCHv2 5/7] web--browse: better support for chromium

On Fri, Dec 3, 2010 at 10:57 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 39 quoted lines
> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
>
>>  init_browser_path() {
>>       browser_path=$(git config "browser.$1.path")
>> +     if test -z "$browser_path" -a "$1" = chromium ; then
>> +             type chromium-browser > /dev/null 2>&1 && browser_path=chromium-browser
>> +     fi
>>       test -z "$browser_path" && browser_path="$1"
>
> We tolerate
>
>        test && test && effect
>
> and even encourage when the construct is short enough, over
>
>        if test && test
>        then
>                effect
>        fi
>
> But because you are writing an "if" block anyway, I think the above should
> be like this:
>
>        if test -z "$browser_path" &&
>           test "$1" = chromium &&
>           type chromium-browser >/dev/null 2>&1
>        then
>                browser_path=chromium-browser
>        fi
>        browser_path=${browser_path:-"$1"}
>
> Yours is:
>
>        if test && test
>        then
>                test && effect
>        fi
>
> which is less than readable, no?

Absolutely. Actually, this final form is a side-effect on some experimentations I was doing, thinking about doing something similar with google-chrome vs chrome (in which case the body of the if would get a case switch or something like that). I'll clean it up, unless somebody can actually confirm that we do want these other special cases.

-- 
Giuseppe "Oblomov" Bilotta
Giuseppe Bilotta· Dec 3, 2010, 16:47 UTC · re: Giuseppe Bilotta · lore

[PATCHv2 6/7] web--browse: use (x-)www-browser if available

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.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 Documentation/git-web--browse.txt |    4 ++
 git-web--browse.sh                |   59 +++++++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index c0416e5..de034a5 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -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/x-www-browser
+(under X) or /usr/bin/www-browser is present, they are used to determine
+the browser to use.
+
 OPTIONS
 -------
 -b <browser>::
diff --git a/git-web--browse.sh b/git-web--browse.sh
index d0e99f5..48ea168 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -49,6 +49,38 @@ init_browser_path() {
 	test -z "$browser_path" && browser_path="$1"
 }
 
+# check if a given executable is a browser we like
+valid_exe() {
+	testexe="$1"
+	basename=$(basename $(readlink -f "$testexe"))
+	if valid_tool "$basename" ; then
+		browser="$basename"
+		browser_path="$testexe"
+		return 0
+	fi
+
+	# if the linked executable doesn't match a browser name,
+	# look at the version string
+	verstring="$("$testexe" --version 2> /dev/null)"
+	browser="$(echo "$verstring" | head -n 1 | cut -f1 -d' ' | tr A-Z a-z)"
+	case "$browser" in
+		mozilla)
+			browser="$(echo "$verstring" | head -n 1 | cut -f2 -d' ' | tr A-Z a-z)"
+			;;
+		google)
+			browser="google-chrome"
+			;;
+	esac
+	if valid_tool "$browser" ; then
+		browser_path="$i"
+		return 0
+	fi
+
+	echo >&2 "$basename ($browser) is not a supported browser, skipping"
+	browser=""
+	return 1
+}
+
 while test $# != 0
 do
 	case "$1" in
@@ -106,6 +138,26 @@ then
 	fi
 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.
+# Otherwise, we warn the user about them being unsupported and proceed to look
+# for a supported browser.
+if test -z "$browser" ; then
+	wwwbrowser="/usr/bin/www-browser"
+	if test -n "$DISPLAY"; then
+		wwwbrowser="/usr/bin/x-www-browser $wwwbrowser"
+		if test -n "$GNOME_DESKTOP_SESSION_ID"; then
+			wwwbrowser="/usr/bin/gnome-www-browser $wwwbrowser"
+		fi
+	fi
+	for i in $wwwbrowser; do
+		if test -x $i && valid_exe $i ; then
+			break
+		fi
+	done
+fi
+
 if test -z "$browser" ; then
 	if test -n "$DISPLAY"; then
 		browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo"
@@ -133,7 +185,7 @@ if test -z "$browser" ; then
 		fi
 	done
 	test -z "$browser" && die "No known browser available."
-else
+else if test -z "$browser_path"; then
 	valid_tool "$browser" || die "Unknown browser '$browser'."
 
 	init_browser_path "$browser"
@@ -141,12 +193,13 @@ else
 	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
+fi fi
 
 case "$browser" in
 firefox|iceweasel|seamonkey|iceape)
 	# Check version because firefox < 2.0 does not support "-new-tab".
-	vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
+	test -z "$verstring" && verstring="$($browser_path -version)"
+	vers=$(expr "$verstring" : '.* \([0-9][0-9]*\)\..*')
 	NEWTAB='-new-tab'
 	test "$vers" -lt 2 && NEWTAB=''
 	"$browser_path" $NEWTAB "$@" &
-- 
1.7.3.2.664.g294b8.dirty
Christian Couder· Dec 3, 2010, 17:40 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2 6/7] web--browse: use (x-)www-browser if available

Hi,

On Fri, Dec 3, 2010 at 5:47 PM, Giuseppe Bilotta <giuseppe.bilotta@gmail.com> wrote:

Show 26 quoted lines
> 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.
>
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
> ---
>  Documentation/git-web--browse.txt |    4 ++
>  git-web--browse.sh                |   59 +++++++++++++++++++++++++++++++++++--
>  2 files changed, 60 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
> index c0416e5..de034a5 100644
> --- a/Documentation/git-web--browse.txt
> +++ b/Documentation/git-web--browse.txt
> @@ -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/x-www-browser
> +(under X) or /usr/bin/www-browser is present, they are used to determine
> +the browser to use.
It looks like /usr/bin/gnome-www-browser is missing.
Show 40 quoted lines
> +
>  OPTIONS
>  -------
>  -b <browser>::
> diff --git a/git-web--browse.sh b/git-web--browse.sh
> index d0e99f5..48ea168 100755
> --- a/git-web--browse.sh
> +++ b/git-web--browse.sh
> @@ -49,6 +49,38 @@ init_browser_path() {
>        test -z "$browser_path" && browser_path="$1"
>  }
>
> +# check if a given executable is a browser we like
> +valid_exe() {
> +       testexe="$1"
> +       basename=$(basename $(readlink -f "$testexe"))
> +       if valid_tool "$basename" ; then
> +               browser="$basename"
> +               browser_path="$testexe"
> +               return 0
> +       fi
> +
> +       # if the linked executable doesn't match a browser name,
> +       # look at the version string
> +       verstring="$("$testexe" --version 2> /dev/null)"
> +       browser="$(echo "$verstring" | head -n 1 | cut -f1 -d' ' | tr A-Z a-z)"
> +       case "$browser" in
> +               mozilla)
> +                       browser="$(echo "$verstring" | head -n 1 | cut -f2 -d' ' | tr A-Z a-z)"
> +                       ;;
> +               google)
> +                       browser="google-chrome"
> +                       ;;
> +       esac
> +       if valid_tool "$browser" ; then
> +               browser_path="$i"
> +               return 0
> +       fi
> +
> +       echo >&2 "$basename ($browser) is not a supported browser, skipping"
Why not:
echo >&2 "$basename (from $testexe) is not a supported browser, skipping"
?
Otherwise we might get something like:
"newbrowser (newbrowser) is not a supported browser, skipping"
Show 40 quoted lines
> +       browser=""
> +       return 1
> +}
> +
>  while test $# != 0
>  do
>        case "$1" in
> @@ -106,6 +138,26 @@ then
>        fi
>  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.
> +# Otherwise, we warn the user about them being unsupported and proceed to look
> +# for a supported browser.
> +if test -z "$browser" ; then
> +       wwwbrowser="/usr/bin/www-browser"
> +       if test -n "$DISPLAY"; then
> +               wwwbrowser="/usr/bin/x-www-browser $wwwbrowser"
> +               if test -n "$GNOME_DESKTOP_SESSION_ID"; then
> +                       wwwbrowser="/usr/bin/gnome-www-browser $wwwbrowser"
> +               fi
> +       fi
> +       for i in $wwwbrowser; do
> +               if test -x $i && valid_exe $i ; then
> +                       break
> +               fi
> +       done
> +fi
> +
>  if test -z "$browser" ; then
>        if test -n "$DISPLAY"; then
>                browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo"
> @@ -133,7 +185,7 @@ if test -z "$browser" ; then
>                fi
>        done
>        test -z "$browser" && die "No known browser available."
> -else
> +else if test -z "$browser_path"; then

Now that you reset $browser above, I am not sure this test -z "$browser_path" is useful...

Thanks, Christian.

Giuseppe Bilotta· Dec 3, 2010, 17:57 UTC · re: Christian Couder · lore

Re: [PATCHv2 6/7] web--browse: use (x-)www-browser if available

On Fri, Dec 3, 2010 at 6:40 PM, Christian Couder <christian.couder@gmail.com> wrote:

Show 9 quoted lines
> Hi,
>
>>  Custom commands may also be specified.
>>
>> +If no default browser is specified, and /usr/bin/x-www-browser
>> +(under X) or /usr/bin/www-browser is present, they are used to determine
>> +the browser to use.
>
> It looks like /usr/bin/gnome-www-browser is missing.
Good catch. I'll add it.
Show 11 quoted lines
>> +       echo >&2 "$basename ($browser) is not a supported browser, skipping"
>
> Why not:
>
> echo >&2 "$basename (from $testexe) is not a supported browser, skipping"
>
> ?
>
> Otherwise we might get something like:
>
> "newbrowser (newbrowser) is not a supported browser, skipping"
I rephrased it to:
	echo >&2 "$testexe (detected as $browser) is not a supported browser, skipping"
Show 9 quoted lines
>> @@ -133,7 +185,7 @@ if test -z "$browser" ; then
>>                fi
>>        done
>>        test -z "$browser" && die "No known browser available."
>> -else
>> +else if test -z "$browser_path"; then
>
> Now that you reset $browser above, I am not sure this test -z
> "$browser_path" is useful...

I believe it is. If the *www-browser detection was successful, _that's_ what we want to launch, so we want to skip the init_browser_path in that else section, which we would hit if we didn't check for $browser_path. We also don't want to repeat the valid_tool check, since we know it's valid already.

-- 
Giuseppe "Oblomov" Bilotta
Junio C Hamano· Dec 3, 2010, 22:15 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2 6/7] web--browse: use (x-)www-browser if available

Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
Show 8 quoted lines
> 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.

A "please step back a bit" question. Does the packaging guideline of Debian say that non-browser applications should take these links as "end user preference" when opening HTML pages?

The behaviour of unconfigured git across platforms would become less consistent if we do this, while the behaviour of random programs on one particular platform (Debian) would become more consistent.

I am not saying that is necessarily a bad thing. I just want to understand the motivation.

> +# check if a given executable is a browser we like
> +valid_exe() {
Call it valid_browser_executable or something, please.
> +	testexe="$1"
> +	basename=$(basename $(readlink -f "$testexe"))

Are we saying "readlink" must exist on the system? This dependency is new, I think.

Giuseppe Bilotta· Dec 3, 2010, 22:45 UTC · re: Junio C Hamano · lore

Re: [PATCHv2 6/7] web--browse: use (x-)www-browser if available

On Fri, Dec 3, 2010 at 11:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
>
>> 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.
>
> A "please step back a bit" question.  Does the packaging guideline of
> Debian say that non-browser applications should take these links as "end
> user preference" when opening HTML pages?

I'm not sure this is an actual guideline, and I cannot find much specific information about it online. It _is_ the recommended way to set the default browser in Debian (plus the BROWSER override), but there are quite a few applications that don't actually follow it. (And FWIW, as a Debian user I find this annoying, e.g. when clicking on a link and having konqueror or iceweasel pop up instead of my preferred x-www-browser, that happens to be Opera.)

I do believe that Debian encourages the use of sensible-browser (that does the BROWSER and *www-browser check itself) rather than manually going to look at those specifications. But that means giving up the "do anything we can to open stuff in a new tab" that is among the specified purposes of git-web--browse.

> The behaviour of unconfigured git across platforms would become less
> consistent if we do this, while the behaviour of random programs on one
> particular platform (Debian) would become more consistent.

That's actually the reason why I wasn't so sure it would be appropriate for inclusion.

> I am not saying that is necessarily a bad thing.  I just want to
> understand the motivation.

The motivation is that, lacking an explicit override, I believe git web--browse should try and get the information about the preferred browser from wherever it can. In a way, the *www-browser testing is akin to the use of start in Windows or open under Mac OS X.

Of course, as I only use Debian, I am not aware of what other distributions do (if they do anything at all) to allow a user to specify a preferred browser.

An alternative approach would be to get rid of the *www-browser and BROWSER patches, and just use xdg-open if it's available. Which again raises the issue of how to enforce opening the page in a new tab.

>> +# check if a given executable is a browser we like
>> +valid_exe() {
>
> Call it valid_browser_executable or something, please.
Of course.
Show 5 quoted lines
>> +     testexe="$1"
>> +     basename=$(basename $(readlink -f "$testexe"))
>
> Are we saying "readlink" must exist on the system?  This dependency is
> new, I think.

The only other use I found of readlink is in a specific area of t/test-lib.sh, so this seems like a new requirement indeed. I can either wrap that part in a type readlink check, or I can get rid of that specific section of the test, and just leave the --version check, bringing the code back to the previous patch version.

-- 
Giuseppe "Oblomov" Bilotta
Jonathan Nieder· Dec 4, 2010, 00:42 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2 6/7] web--browse: use (x-)www-browser if available

Giuseppe Bilotta wrote:
> I do believe that Debian encourages the use of sensible-browser (that
> does the BROWSER and *www-browser check itself) rather than manually
> going to look at those specifications.

My impression (by analogy with policy §11.4 "Editors and pagers") is that one is encouraged to make the default configurable at compile time and use

 - first $BROWSER
 - then something desktop-specific
 - then the configured default

and set that default to www-browser or x-www-browser, depending on whether your program uses X. That way, non-Debian systems benefit from the changes you introduce, too.

> An alternative approach would be to get rid of the *www-browser and
> BROWSER patches, and just use xdg-open if it's available. Which again
> raises the issue of how to enforce opening the page in a new tab.

Yes, in this case that is the ideal (assuming xdg-utils has wide enough adoption).

I think xdg-open has just as much a reason as we do to encourage opening the page in a new tab. Would it be hard to make that happen?

Giuseppe Bilotta· Dec 4, 2010, 07:49 UTC · re: Jonathan Nieder · lore

Re: [PATCHv2 6/7] web--browse: use (x-)www-browser if available

On Sat, Dec 4, 2010 at 1:42 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 17 quoted lines
> Giuseppe Bilotta wrote:
>
>> I do believe that Debian encourages the use of sensible-browser (that
>> does the BROWSER and *www-browser check itself) rather than manually
>> going to look at those specifications.
>
> My impression (by analogy with policy §11.4 "Editors and pagers") is
> that one is encouraged to make the default configurable at compile
> time and use
>
>  - first $BROWSER
>  - then something desktop-specific
>  - then the configured default
>
> and set that default to www-browser or x-www-browser, depending on
> whether your program uses X.  That way, non-Debian systems benefit
> from the changes you introduce, too.

I'm not entirely sure how non-Debian would benefit from the change at the current state, but I'm willing to present patches for the mechanism offered by other distributions (e.g. does anybody know how RedHad/Fedora sets the preferred browser?)

Show 9 quoted lines
>> An alternative approach would be to get rid of the *www-browser and
>> BROWSER patches, and just use xdg-open if it's available. Which again
>> raises the issue of how to enforce opening the page in a new tab.
>
> Yes, in this case that is the ideal (assuming xdg-utils has wide
> enough adoption).
>
> I think xdg-open has just as much a reason as we do to encourage
> opening the page in a new tab.  Would it be hard to make that happen?

I have no idea. Also, it's sort-of outside the scope of our reach, and we would have to wait for a change in that effect to 'trickle down'.

-- 
Giuseppe "Oblomov" Bilotta
Giuseppe Bilotta· Dec 3, 2010, 16:47 UTC · re: Giuseppe Bilotta · lore

[PATCHv2 7/7] web--browse: look at the BROWSER env var

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.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-web--browse.sh |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 48ea168..e3dbbe3 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -138,6 +138,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_exe "$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.
-- 
1.7.3.2.664.g294b8.dirty
Jonathan Nieder· Dec 3, 2010, 17:08 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2 7/7] web--browse: look at the BROWSER env var

Giuseppe Bilotta wrote:
> --- a/git-web--browse.sh
> +++ b/git-web--browse.sh
> @@ -138,6 +138,51 @@ then
[...]
> +if test -z "$browser" -a -n "$BROWSER"; then
> +	OLDIFS="$IFS"
> +	IFS=:
[...]
> +	IFS="$OLDIFS"
Micronit: on some shells (e.g., old ash[1]), IFS starts out unset if
it hasn't been inherited in the environment.  How about something like
this?
	LF="
"
	usual_ifs=" 	$LF"
	IFS=:
	...
				IFS=$usual_ifs
	...
	IFS=$usual_ifs

Based on [2] I would guess that any POSIX-style shell would also support

	IFS=:
	...
				unset IFS
	...
	unset IFS
but maybe that's playing with fire.
The rest of this series looks quite nice, so
Acked-by: Jonathan Nieder <jrnieder@gmail.com>

[1] http://bugs.debian.org/95856 [2] http://www.in-ulm.de/~mascheck/various/ifs/

Jonathan Nieder· Dec 3, 2010, 17:16 UTC · re: Jonathan Nieder · lore

Re: [PATCHv2 7/7] web--browse: look at the BROWSER env var

Jonathan Nieder wrote:
> Giuseppe Bilotta wrote:
Show 12 quoted lines
>> --- a/git-web--browse.sh
>> +++ b/git-web--browse.sh
>> @@ -138,6 +138,51 @@ then
>[...]
>> +if test -z "$browser" -a -n "$BROWSER"; then
>> +	OLDIFS="$IFS"
>> +	IFS=:
>[...]
>> +	IFS="$OLDIFS"
>
> Micronit: on some shells (e.g., old ash[1]), IFS starts out unset if
> it hasn't been inherited in the environment.

Of course, we are using this idiom in a few places already, so that can be saved for another topic. Sorry for not checking sooner.

← back to recent threads