From: Scott Lamb <slamb@slamb.org>
To: Steffen Prohaska <prohaska@zib.de>
Cc: Theodore Tso <tytso@mit.edu>, Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] mergetool: make Apple's FileMerge available as a merge_tool
Date: Mon, 18 Jun 2007 02:39:08 -0700 [thread overview]
Message-ID: <467652BC.4050900@slamb.org> (raw)
In-Reply-To: <42FEB11E-426D-4B44-9E7E-0E35032CB1B0@zib.de>
Steffen Prohaska wrote:
>
> On Jun 17, 2007, at 8:12 PM, Theodore Tso wrote:
>> Do you know of a way of determining whether or not under MacOS X, a
>> program can easily determine whether or not the user is sitting in
>> front of the graphical display, as opposed to coming in via an SSH
>> connection?
>
> this might do the job:
>
> --- SNIP ---
> #! /bin/sh
>
> pid=$$
>
> while [ $pid -ne 1 ] ; do
> command=$(ps -p $pid | tail -n 1 | cut -b 27-)
> echo $command | grep -q sshd && { echo "ssh" ; exit ; }
> echo $command | grep -q Terminal && { echo "local" ; exit ; }
> pid=$(ps -O ppid -p $pid | tail -n 1 | cut -b 6-11)
> done
>
> echo "unknown"
> --- SNIP ---
I propose a simpler test:
if [ -n "$TERM_PROGRAM" ]; then
echo local
else
echo remote
fi
This environment variable seems to be set by Terminal.app and even two
alternatives I just tried (iTerm.app and GLterm.app). It's not
transmitted across ssh unless you stick an AcceptEnv in sshd_config.
About the only time it would fail is logging in via local xterm. I'd
guess few people do that, and determining if xterm is local or not seems
infeasible - the best I've got is examining DISPLAY, but where do you
draw the line between :0.0 or localhost:0 (probably local), foobar:0
(probably remote), and :10 (probably remote via ssh forwarding)? I'd
rather not try.
--
Scott Lamb <http://www.slamb.org/>
next prev parent reply other threads:[~2007-06-18 9:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-17 15:59 [PATCH] mergetool: make Apple's FileMerge available as a merge_tool Steffen Prohaska
2007-06-17 16:13 ` Steffen Prohaska
2007-06-17 18:12 ` Theodore Tso
2007-06-17 19:20 ` Steffen Prohaska
2007-06-18 9:39 ` Scott Lamb [this message]
2007-06-18 13:18 ` Theodore Tso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=467652BC.4050900@slamb.org \
--to=slamb@slamb.org \
--cc=git@vger.kernel.org \
--cc=prohaska@zib.de \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.