From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25466 invoked from network); 18 Jan 2005 03:07:19 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 Jan 2005 03:07:19 -0000 Received: (qmail 50246 invoked from network); 18 Jan 2005 03:07:11 -0000 Received: from unknown (HELO sunsite.dk) (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Jan 2005 03:07:11 -0000 Received: (qmail 7040 invoked by alias); 17 Jan 2005 16:00:03 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8385 Received: (qmail 7011 invoked from network); 17 Jan 2005 16:00:02 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Jan 2005 16:00:02 -0000 Received: (qmail 78353 invoked from network); 17 Jan 2005 16:00:02 -0000 Received: from adsl-216-158-26-62.cust.oldcity.dca.net (HELO spacecat.mcgillsociety.org) (216.158.26.62) by a.mx.sunsite.dk with SMTP; 17 Jan 2005 15:59:57 -0000 Received: from [10.0.1.2] (abase.mcgillsociety.org [216.158.26.165]) by spacecat.mcgillsociety.org (8.11.3/8.11.3) with ESMTP id j0HFvll368950; Mon, 17 Jan 2005 10:57:47 -0500 (EST) In-Reply-To: <1050116063300.ZM23267@candle.brasslantern.com> References: <200501160216.15097.toshiro@internet.com.uy> <1050116063300.ZM23267@candle.brasslantern.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: zsh-users@sunsite.dk, Toshiro X-Image-Url: http://www.mcgillsociety.org/magill.jpg From: "William H. Magill" Subject: Re: bug (feature?) in zsh Date: Mon, 17 Jan 2005 10:59:54 -0500 To: Bart Schaefer X-Mailer: Apple Mail (2.619) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On 16 Jan, 2005, at 01:33, Bart Schaefer wrote: > On Jan 16, 2:16am, Toshiro wrote: > } Subject: bug (feature?) in zsh > } > } I'm using Debian unstable, zsh version 4.2.2. I've noticed that, > when I > } install a new package that puts some program in my path (for > } example, /usr/bin) I can't invoke the program using completion in > any zsh > } shell that I have opened before installing the program. > > This is almost reaching FAQ status, but isn't yet in the FAQ. > > The completion system (including compctl) uses the command hash table > to > look up names for completion in command position, because it's > expensive > to search the path for them. That means that if you install some new > piece of software, you need to run 'rehash' before the completion > system > will see it, as you discovered. > > See the zsh-users thread with subject "HASH_LIST_ALL?" from October > 2004 > for more discussion; in particular, article 8059 presents a technique > for working around this behavior The use of a hash table for command execution/completion was implemented with csh -- many, many years ago. Those shells which have descended from csh (tcsh, zsh) behave in this same fashion. It is the expected behavior. Sh behavior was always different. It did not use a hash table. Consequently shells which descended from sh (new sh, bash, ksh) do not have a hash table. This difference was mainly because the "csh" was intended as an "interactive" shell, and therefore included features (like command completion) which made usage on what at the time were the standard input devices -- 110 baud ttys -- much easier on the operator. By comparison, sh, was deemed a "batch" shell where the full command paths were expected to be utilized, both as "documentation" in the script and to assure that the "environment" used by the shell was explicitly what the script writer wanted, and not that of the entity using the shell. (Note that this is still considered "Best Practice." And that it is required for most implementations of "cron" in use today -- the environment available to the cron job is that of process 1, NOT that of the User.) Note also that I use the term "descended from" quite liberally. In the beginning there was only Bell Labs and it was called "sh." "sh" was replaced by "new sh" (frequently called sh5) when it became System V. Meanwhile BSD created csh to run on top of sh. All Unix variants and Linux variants boot into some form of "sh." Today, I believe all variants of Unix and Linux run "new sh" for process 0, which in turn spawns init. Only after User processes are spawned do the /etc/shells options come into play. That this is not in the FAQ is not really surprising. Interesting, but not surprising. For some strange reason, throughout the history of Unix, the concept of "rehash" has always been a deeply guarded secret of the Unix Wizards ... only taught to the truly deserving; neophytes who sought to follow the ways of the guru. Others were simply told, "Logout and log back in, and it will work." For the record, the "strange reason" is the difference between the "System Administrator" (aka root) and the "User" -- everybody else. The System Administrator is technically the only one who installs (or can install) software available to anyone other than the person installing it. "Technically," the System Administrator only does such a thing on a "closed" system -- i.e. one not permitting user logins (/etc/nologin). Therefore, the SysAdmin needs to "rehash" for testing purposes, but everyone else will "automagically" see the new information when they login. Today, there are probably far more "SysAdmins" supporting "single-user" boxes, especially under Linux, than there are SysAdmins supporting multi-user, time-sharing systems. This is especially true with the widespread use of sudo as opposed to actually logging in as the root user. T.T.F.N. William H. Magill # Beige G3 [Rev A motherboard - 300 MHz 768 Meg] OS X 10.2.8 # Flat-panel iMac (2.1) [800MHz - Super Drive - 768 Meg] OS X 10.3.7 # PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg] Tru64 5.1a # XP1000 [Alpha 21264-3 (EV6) - 256 meg] FreeBSD 5.3 # XP1000 [Alpha 21264-A (EV 6.7) - 384 meg] FreeBSD 5.3 magill@mcgillsociety.org magill@acm.org magill@mac.com whmagill@gmail.com