Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: $HOST on OS X
- X-seq: zsh-users 15089
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: "William G. Scott" <wgscott@xxxxxxxxxxxxxxxxxx>
- Subject: Re: $HOST on OS X
- Date: Sat, 5 Jun 2010 11:45:26 -0400 (EDT)
- Cc: zsh-users@xxxxxxx
- In-reply-to: <alpine.LNX.2.01.1006051125040.5029@xxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <A31BDCF6-D2C6-4674-B4D5-86B60347A0B2@xxxxxxxxxxxxxxxxxx> <16277B2D-B9C7-4B56-A74C-AE6266BDA089@xxxxxxxxxxxxxxxxxx> <alpine.LNX.2.01.1006051125040.5029@xxxxxxxxxxx>
On Sat, 5 Jun 2010, Benjamin R. Haskell wrote:
> On Sat, 5 Jun 2010, William G. Scott wrote:
>
> > Dear citizens:
> >
> > I just noticed odd behavior for how $HOST is getting set on OS X v.
> > 10.6.3.
> >
> > One one home machine connected to a wireless router and ADSL modem:
> >
> > % print $HOST
> > internalcheck.apple.com
> >
> > On another -- This one worries me more:
> >
> > % print $HOST
> > e3191.c.akamaiedge.net
> >
> > The manual says $HOST is automatically set by the shell, but I wonder
> > how this is happening? I don't have anything weird in /etc/hosts for
> > example...
>
> $HOST is set by the following lines in Src/params.c:
>
> 682 hostnam = (char *)zalloc(256);
> 683 gethostname(hostnam, 256);
> 684 setsparam("HOST", ztrdup(hostnam));
>
> If gethostname is defined in unistd.h, it's a standard library call that
> fills its char* first parameter with your hostname. Otherwise, there's
> a compatibility replacement in Src/compat.c that basically gets the node
> name via uname. Omitting error-checking, it's:
>
> int gethostname(char*name, size_t namelen) {
> struct utsname uts;
> uname(&uts);
> strcpy(name,uts.nodename);
> }
>
> So, either way, it follows a pretty standard path to getting a hostname.
>
> I'm not sure whether OS X would have gethostname, but what does `uname
> -n` return? Or `hostname`?
I also neglected to mention that $HOST can be inherited from the
environment.
e.g.:
$ HOST=whatever zsh -c 'echo $HOST'
whatever
$
So, maybe there was some script you/someone ran that set
HOST=e3191.c.akamaiedge.net, for convenience. (For uploading things to
Akamai's CDN, maybe? Seems a bit of a stretch.)
--
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author