# Fwd: Bug: git web--browse doesn't recognise browser on OS X

11 messages from 2013-03-14 to 2013-04-04. Participants: Timo Sand, Christian Couder, John Szakmeister, Junio C Hamano.
Thread: https://gitlist.dev/t/33178

## Timo Sand, 2013-03-14 11:39

Subject: Fwd: Bug: git web--browse doesn't recognise browser on OS X
Message-ID: <CAMxBVStw-b3J_Fm9x=h3==9ebdLUkpjBSQ9-W4+zJ9N20ojfxg@mail.gmail.com>
URL: https://gitlist.dev/e/CAMxBVStw-b3J_Fm9x%3Dh3%3D%3D9ebdLUkpjBSQ9-W4%2BzJ9N20ojfxg%40mail.gmail.com
In-Reply-To: <CAMxBVSs6dJFnK78E2Da7t4V9ndJFRVDZEd1fR5QuCFz=u2Bnpw@mail.gmail.com>

```
Hi

I tried to open a website by runnin 'git web--browse http://google.com'
and it replied 'No known browser available'.
I also tried with '--browser=chrome' and '--browser=google-chrome' but
the responded with 'The browser chrome is not available as 'chrome'.'

I expected the command to open a new tab in my browser in each of the 3 tries.
This has worked for my system before.

OS X 10.8.2, git 1.8.2, Google Chrome 27.0.1438.7 dev

--
Timo Sand
timo.j.sand+sig@gmail.com

```

## Christian Couder, 2013-03-15 11:19

Subject: Re: Bug: git web--browse doesn't recognise browser on OS X
Message-ID: <CAP8UFD2oR5tnYuw7Nbe-CzGx7fw-OpAFW+reN+1Nroh1jXjfsQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAP8UFD2oR5tnYuw7Nbe-CzGx7fw-OpAFW%2BreN%2B1Nroh1jXjfsQ%40mail.gmail.com
In-Reply-To: <CAMxBVStw-b3J_Fm9x=h3==9ebdLUkpjBSQ9-W4+zJ9N20ojfxg@mail.gmail.com>

```
Hi,

On Thu, Mar 14, 2013 at 12:39 PM, Timo Sand <timo.j.sand@gmail.com> wrote:
> Hi
>
> I tried to open a website by runnin 'git web--browse http://google.com'
> and it replied 'No known browser available'.

First git web--browse is a plumbing shell script to display
documentation on a web browser when you type something like "git help
-w log".
It is not really supposed to be used directly by the user. On OS X it
might be simpler to just type "open http://google.com".

That said there is the following in it to make it work on OS X:

# SECURITYSESSIONID indicates an OS X GUI login session
if test -n "$SECURITYSESSIONID" \
-o "$TERM_PROGRAM" = "Apple_Terminal" ; then
browser_candidates="open $browser_candidates"
fi

So I guess that you don't have SECURITYSESSIONID set in your terminal
and you are not using Apple Terminal.

As I am not using OS X, I have no idea how to improve the script in this case.

> I also tried with '--browser=chrome' and '--browser=google-chrome' but
> the responded with 'The browser chrome is not available as 'chrome'.'

Could you try something like: "chromium http://google.com" or
"chromium-browser http://google.com"
If it works, then using 'git web--browse' with '--browser=chromium' or
'--browser=chromium-browser' should work.

Otherwise did you try "chrome http://google.com" and "google-chrome
http://google.com"?

> I expected the command to open a new tab in my browser in each of the 3 tries.
> This has worked for my system before.
>
> OS X 10.8.2, git 1.8.2, Google Chrome 27.0.1438.7 dev

Thanks,
Christian.

```

## Timo Sand, 2013-03-22 16:19

Subject: Re: Bug: git web--browse doesn't recognise browser on OS X
Message-ID: <CAMxBVStVXZGGrjHzN7kukVP6_ZGo0miyJaE2FVYPVV4Jb5U82w@mail.gmail.com>
URL: https://gitlist.dev/e/CAMxBVStVXZGGrjHzN7kukVP6_ZGo0miyJaE2FVYPVV4Jb5U82w%40mail.gmail.com
In-Reply-To: <CAP8UFD2oR5tnYuw7Nbe-CzGx7fw-OpAFW+reN+1Nroh1jXjfsQ@mail.gmail.com>

```
Hi,

well my use case is actually that I'm trying to use the gem
'gem-browse' which uses 'git web--browse'
I'm not using Apple Terminal, I'm using iTerm2 and there doesn't seem
to be a SECURITYSESSIONID set, at least echo didn't find any. But
neither did I find it on Apple Terminal either.

What troubles me is that this issue has only arisen recently, earlier
this worked fine for me

On 15 March 2013 11:19, Christian Couder <christian.couder@gmail.com> wrote:
> Hi,
>
> On Thu, Mar 14, 2013 at 12:39 PM, Timo Sand <timo.j.sand@gmail.com> wrote:
>> Hi
>>
>> I tried to open a website by runnin 'git web--browse http://google.com'
>> and it replied 'No known browser available'.
>
> First git web--browse is a plumbing shell script to display
> documentation on a web browser when you type something like "git help
> -w log".
> It is not really supposed to be used directly by the user. On OS X it
> might be simpler to just type "open http://google.com".
>
> That said there is the following in it to make it work on OS X:
>
> # SECURITYSESSIONID indicates an OS X GUI login session
> if test -n "$SECURITYSESSIONID" \
> -o "$TERM_PROGRAM" = "Apple_Terminal" ; then
> browser_candidates="open $browser_candidates"
> fi
>
> So I guess that you don't have SECURITYSESSIONID set in your terminal
> and you are not using Apple Terminal.
>
> As I am not using OS X, I have no idea how to improve the script in this case.
>
>> I also tried with '--browser=chrome' and '--browser=google-chrome' but
>> the responded with 'The browser chrome is not available as 'chrome'.'
>
> Could you try something like: "chromium http://google.com" or
> "chromium-browser http://google.com"
> If it works, then using 'git web--browse' with '--browser=chromium' or
> '--browser=chromium-browser' should work.
>
> Otherwise did you try "chrome http://google.com" and "google-chrome
> http://google.com"?
>
>> I expected the command to open a new tab in my browser in each of the 3 tries.
>> This has worked for my system before.
>>
>> OS X 10.8.2, git 1.8.2, Google Chrome 27.0.1438.7 dev
>
> Thanks,
> Christian.



-- 
Timo Sand
timo.j.sand+sig@gmail.com

```

## John Szakmeister, 2013-03-22 17:36

Subject: Re: Bug: git web--browse doesn't recognise browser on OS X
Message-ID: <CAEBDL5VNodcTGBOvQjyL30qiXhshxhnUH-Vd9xy9=RxZQgH-Yw@mail.gmail.com>
URL: https://gitlist.dev/e/CAEBDL5VNodcTGBOvQjyL30qiXhshxhnUH-Vd9xy9%3DRxZQgH-Yw%40mail.gmail.com
In-Reply-To: <CAMxBVStVXZGGrjHzN7kukVP6_ZGo0miyJaE2FVYPVV4Jb5U82w@mail.gmail.com>

```
On Fri, Mar 22, 2013 at 12:19 PM, Timo Sand <timo.j.sand@gmail.com> wrote:
> Hi,
>
> well my use case is actually that I'm trying to use the gem
> 'gem-browse' which uses 'git web--browse'
> I'm not using Apple Terminal, I'm using iTerm2 and there doesn't seem
> to be a SECURITYSESSIONID set, at least echo didn't find any. But
> neither did I find it on Apple Terminal either.

I noticed this the other day, but I think SECURITYSESSIONID only gets
set when Screen Sharing is enabled.  I had Screen Sharing enabled,
launched iTerm2 and saw the variable.  I closed iTerm2, turned off
Screen Sharing, and relaunched iTerm2 to find the variable missing.
As a result, I'm not SECURITYSESSIONID is a good mechanism for
determining whether the terminal is associated a GUI or not.
Unfortunately, I don't know of a better way.

> What troubles me is that this issue has only arisen recently, earlier
> this worked fine for me

The following patch fixes the issue by recognizing iTerm2 as a GUI terminal.

-John

>From 5d282325f9374b25609a8704661c252304b4d18a Mon Sep 17 00:00:00 2001
Date: Fri, 22 Mar 2013 13:23:07 -0400
Subject: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X

Signed-off-by: John Szakmeister <john@szakmeister.net>
---
 git-web--browse.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/git-web--browse.sh b/git-web--browse.sh
index 1e82726..1ff5379 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -120,6 +120,7 @@ if test -z "$browser" ; then
 	fi
 	# SECURITYSESSIONID indicates an OS X GUI login session
 	if test -n "$SECURITYSESSIONID" \
+		-o "$TERM_PROGRAM" = "iTerm.app" \
 		-o "$TERM_PROGRAM" = "Apple_Terminal" ; then
 		browser_candidates="open $browser_candidates"
 	fi
-- 
1.8.1.1

```

## Christian Couder, 2013-03-24 21:05

Subject: Re: Bug: git web--browse doesn't recognise browser on OS X
Message-ID: <CAP8UFD2m8n5RHN-CgyDP1ir_AorpJGnWwNhXuRxDa=DbHfsdiw@mail.gmail.com>
URL: https://gitlist.dev/e/CAP8UFD2m8n5RHN-CgyDP1ir_AorpJGnWwNhXuRxDa%3DDbHfsdiw%40mail.gmail.com
In-Reply-To: <CAEBDL5VNodcTGBOvQjyL30qiXhshxhnUH-Vd9xy9=RxZQgH-Yw@mail.gmail.com>

```
On Fri, Mar 22, 2013 at 6:36 PM, John Szakmeister <john@szakmeister.net> wrote:
> On Fri, Mar 22, 2013 at 12:19 PM, Timo Sand <timo.j.sand@gmail.com> wrote:
>> Hi,
>>
>> well my use case is actually that I'm trying to use the gem
>> 'gem-browse' which uses 'git web--browse'
>> I'm not using Apple Terminal, I'm using iTerm2 and there doesn't seem
>> to be a SECURITYSESSIONID set, at least echo didn't find any. But
>> neither did I find it on Apple Terminal either.
>
> I noticed this the other day, but I think SECURITYSESSIONID only gets
> set when Screen Sharing is enabled.  I had Screen Sharing enabled,
> launched iTerm2 and saw the variable.  I closed iTerm2, turned off
> Screen Sharing, and relaunched iTerm2 to find the variable missing.
> As a result, I'm not SECURITYSESSIONID is a good mechanism for
> determining whether the terminal is associated a GUI or not.
> Unfortunately, I don't know of a better way.
>
>> What troubles me is that this issue has only arisen recently, earlier
>> this worked fine for me
>
> The following patch fixes the issue by recognizing iTerm2 as a GUI terminal.

Your patch looks good to me, and I cannot really test it as I don't have a Mac.
Could you just had some of the explanations you gave above to the
commit message?

Thanks,
Christian.

```

## John Szakmeister, 2013-03-25 10:13

Subject: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X
Message-ID: <20130325101318.GA31409@yoda.local>
URL: https://gitlist.dev/e/20130325101318.GA31409%40yoda.local
In-Reply-To: <CAP8UFD2m8n5RHN-CgyDP1ir_AorpJGnWwNhXuRxDa=DbHfsdiw@mail.gmail.com>

```
It turns out that the presence of SECURITYSESSIONID is not sufficient
for detecting the presence of a GUI under Mac OS X.  SECURITYSESSIONID
appears to only be set when the user has Screen Sharing enabled.
Disabling Screen Sharing and relaunching the shell showed that the
variable was missing, at least under Mac OS X 10.6.8.  As a result,
let's check for iTerm directly via TERM_PROGRAM.

Signed-off-by: John Szakmeister <john@szakmeister.net>
---

On Sun, Mar 24, 2013 at 10:05:53PM +0100, Christian Couder wrote:
[snip]
> Your patch looks good to me, and I cannot really test it as I don't have a Mac.
> Could you just had some of the explanations you gave above to the
> commit message?

Here's an updated patch.  I also noticed that git-bisect.sh is
also trying to determine if a GUI is present by looking for
SECURITYSESSIONID as well.  I wonder if it would be better to
create a shell function in git-sh-setup.sh that the two scripts
could use?

-John

git-web--browse.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/git-web--browse.sh b/git-web--browse.sh
index 1e82726..1ff5379 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -120,6 +120,7 @@ if test -z "$browser" ; then
 	fi
 	# SECURITYSESSIONID indicates an OS X GUI login session
 	if test -n "$SECURITYSESSIONID" \
+		-o "$TERM_PROGRAM" = "iTerm.app" \
 		-o "$TERM_PROGRAM" = "Apple_Terminal" ; then
 		browser_candidates="open $browser_candidates"
 	fi
-- 
1.8.2

```

## Christian Couder, 2013-03-25 20:13

Subject: Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X
Message-ID: <CAP8UFD21BChC-KF+HWWS9_q_GtpGm+Uh_L60qcJt=b3mQt_jBw@mail.gmail.com>
URL: https://gitlist.dev/e/CAP8UFD21BChC-KF%2BHWWS9_q_GtpGm%2BUh_L60qcJt%3Db3mQt_jBw%40mail.gmail.com
In-Reply-To: <20130325101318.GA31409@yoda.local>

```
On Mon, Mar 25, 2013 at 11:13 AM, John Szakmeister <john@szakmeister.net> wrote:
>
> Here's an updated patch.

Thank you for it. For what it's worth:

Acked-by: Christian Couder <chriscool@tuxfamily.org>

> I also noticed that git-bisect.sh is
> also trying to determine if a GUI is present by looking for
> SECURITYSESSIONID as well.  I wonder if it would be better to
> create a shell function in git-sh-setup.sh that the two scripts
> could use?

Yeah, it might be a good idea to have some common functions to
determine if a GUI is present.
Maybe you could start with an os_x_gui_present() function in another
patch on top of this one.

Thanks,
Christian.

```

## Junio C Hamano, 2013-03-25 21:44

Subject: Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X
Message-ID: <7vtxnzw3wu.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtxnzw3wu.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20130325101318.GA31409@yoda.local>

```
John Szakmeister <john@szakmeister.net> writes:

> It turns out that the presence of SECURITYSESSIONID is not sufficient
> for detecting the presence of a GUI under Mac OS X.  SECURITYSESSIONID
> appears to only be set when the user has Screen Sharing enabled.
> Disabling Screen Sharing and relaunching the shell showed that the
> variable was missing, at least under Mac OS X 10.6.8.  As a result,
> let's check for iTerm directly via TERM_PROGRAM.
>
> Signed-off-by: John Szakmeister <john@szakmeister.net>
> ---
>
> On Sun, Mar 24, 2013 at 10:05:53PM +0100, Christian Couder wrote:
> [snip]
>> Your patch looks good to me, and I cannot really test it as I don't have a Mac.
>> Could you just had some of the explanations you gave above to the
>> commit message?
>
> Here's an updated patch.  I also noticed that git-bisect.sh is
> also trying to determine if a GUI is present by looking for
> SECURITYSESSIONID as well.  I wonder if it would be better to
> create a shell function in git-sh-setup.sh that the two scripts
> could use?

Yes, but that can come later once this settles.

Your patch makes me wonder if

	test -n "$TERM_PROGRAM"

without any SECURITYSESSIONID or explicit program name checks should
suffice, though.

>
> -John
>
> git-web--browse.sh | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/git-web--browse.sh b/git-web--browse.sh
> index 1e82726..1ff5379 100755
> --- a/git-web--browse.sh
> +++ b/git-web--browse.sh
> @@ -120,6 +120,7 @@ if test -z "$browser" ; then
>  	fi
>  	# SECURITYSESSIONID indicates an OS X GUI login session
>  	if test -n "$SECURITYSESSIONID" \
> +		-o "$TERM_PROGRAM" = "iTerm.app" \
>  		-o "$TERM_PROGRAM" = "Apple_Terminal" ; then
>  		browser_candidates="open $browser_candidates"
>  	fi

```

## John Szakmeister, 2013-03-26 08:54

Subject: Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X
Message-ID: <CAEBDL5Vx0vjAKUeFrXgpx7mYxk8B+OQC5yrEii9RMP-5-Sjhsw@mail.gmail.com>
URL: https://gitlist.dev/e/CAEBDL5Vx0vjAKUeFrXgpx7mYxk8B%2BOQC5yrEii9RMP-5-Sjhsw%40mail.gmail.com
In-Reply-To: <7vtxnzw3wu.fsf@alter.siamese.dyndns.org>

```
Sorry about the repeat Junio, I meant to hit "Reply to All".

On Mon, Mar 25, 2013 at 5:44 PM, Junio C Hamano <gitster@pobox.com> wrote:
[snip]
> Your patch makes me wonder if
>
>         test -n "$TERM_PROGRAM"
>
> without any SECURITYSESSIONID or explicit program name checks should
> suffice, though.

So, after downloading a couple of other terminals and trying things
out, I think you're suggestion does suffice.  Should I send an updated
patch?

-John

```

## Junio C Hamano, 2013-03-27 14:43

Subject: Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X
Message-ID: <7vfvzgrjgz.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vfvzgrjgz.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAEBDL5Vx0vjAKUeFrXgpx7mYxk8B+OQC5yrEii9RMP-5-Sjhsw@mail.gmail.com>

```
John Szakmeister <john@szakmeister.net> writes:

> Sorry about the repeat Junio, I meant to hit "Reply to All".
>
> On Mon, Mar 25, 2013 at 5:44 PM, Junio C Hamano <gitster@pobox.com> wrote:
> [snip]
>> Your patch makes me wonder if
>>
>>         test -n "$TERM_PROGRAM"
>>
>> without any SECURITYSESSIONID or explicit program name checks should
>> suffice, though.
>
> So, after downloading a couple of other terminals and trying things
> out, I think you're suggestion does suffice.  Should I send an updated
> patch?

If that approach is better than what you originally sent, then yes.

But I do not use OS X, so you may need to pay attention to possible
complaints and comments from other Mac users on this list for a
while---there may be people who run the program in question without
that environment variable.

```

## John Szakmeister, 2013-04-04 00:10

Subject: Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X
Message-ID: <CAEBDL5WEChOgG2XVML=tjWtUgp4_5nQq-KqQv-h79tgaDTx9bA@mail.gmail.com>
URL: https://gitlist.dev/e/CAEBDL5WEChOgG2XVML%3DtjWtUgp4_5nQq-KqQv-h79tgaDTx9bA%40mail.gmail.com
In-Reply-To: <7vfvzgrjgz.fsf@alter.siamese.dyndns.org>

```
On Wed, Mar 27, 2013 at 10:43 AM, Junio C Hamano <gitster@pobox.com> wrote:
[snip]
> If that approach is better than what you originally sent, then yes.
>
> But I do not use OS X, so you may need to pay attention to possible
> complaints and comments from other Mac users on this list for a
> while---there may be people who run the program in question without
> that environment variable.

Sorry it has taken me so long to get back to this.  I searched around
and tried out a few terminal programs that are available, and I think
what you queued--checking that TERM_PROGRAM is non-empty--is the right
fix.

Thanks!

-John

```
