From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24469 invoked by alias); 5 Jun 2010 15:45:32 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15089 Received: (qmail 6479 invoked from network); 5 Jun 2010 15:45:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Sat, 5 Jun 2010 11:45:26 -0400 (EDT) From: "Benjamin R. Haskell" To: "William G. Scott" cc: zsh-users@zsh.org Subject: Re: $HOST on OS X In-Reply-To: Message-ID: References: <16277B2D-B9C7-4B56-A74C-AE6266BDA089@chemistry.ucsc.edu> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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