Re: [PATCH] mergetool: make Apple's FileMerge available as a merge_tool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/>

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux