From owner-freebsd-questions Fri Dec 14 22:39:20 2001 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-11.mail.nl.demon.net [194.159.73.21]) by hub.freebsd.org (Postfix) with ESMTP id BAA4237B416 for ; Fri, 14 Dec 2001 22:39:16 -0800 (PST) Received: from [212.238.194.207] (helo=tanya.raggedclown.net) by post.mail.nl.demon.net with esmtp (Exim 3.33 #1) id 16F8Tb-000Dgz-00 for freebsd-questions@FreeBSD.ORG; Sat, 15 Dec 2001 06:39:15 +0000 Received: by tanya.raggedclown.net (tanya.raggedclown.net, from userid 500) id 1C5051138; Sat, 15 Dec 2001 07:39:14 +0100 (CET) Date: Sat, 15 Dec 2001 07:39:13 +0100 From: Cliff Sarginson To: Freebsd-questions Subject: Re: whats this?! Message-ID: <20011215063913.GA7022@raggedclown.net> References: <200112132105.QAA16995@uce55.uchaswv.edu> <20011213164200.N94620-100000@catalyst.sasknow.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011213164200.N94620-100000@catalyst.sasknow.net> User-Agent: Mutt/1.3.24i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Dec 13, 2001 at 04:47:03PM -0600, Ryan Thompson wrote: > Nathan Mace wrote to Freebsd-questions: > > > type 'cd //' and then do a pwd. > > > > what causes this? found it by accident > > I think it's a parsing [bug|feature] in bash. Slashes are normally > condensed. At least, I have only noticed this peculiarity in bash. > The standard shells (sh, [t]csh) do not appear to be affected. > > Probably it is because bash tries to use "friendly" pathnames (i.e., > displays ~/username instead of /usr/home/username), thus circumventing > nice things like realpath(3). > > In any case, when bash actually passes the pathname to any of the > library path routines, the slashes WILL eventually get condensed, so > this shouldn't affect operation at all. > Out of curiosity I tried a few expriments, since I have noticed that bash does this, but only with 2 leading "/"s. It correctly throws away multiple slashes in subsequent elements of a path name. In tcsh you can also have multiple slashes anywhwere in a pathname and it just throws them away. Internally it also records what you typed in, with 2 leading slashes, but subsequent multiple occurences suppressed. Even more amusing is $OLDPWD, which faithfully copies $PWD when you cd. So if you manually set $PWD to something nonsensical, "pwd" still reflects where you really are. Now cd to somewhere else and try "cd -" it then does use OLDPWD and of course gets an error. I say of course, but it does some slightly odd that the shell does not remember the real old pwd, the externally visible one not being that robust a mechanism. The upshot of all this timewasting (by me!) is that multiple "//"s in pathnames are not illegal, they just get parsed out as empty components. i.e. "//" is the same as "/./" practically speaking. However an absolute pathname is quite a diferent animal to a relative one if you think about it. The shell does not need to know where it is to do a cd in this case. Hence the logic for an absolute pathname is probably seperate, or at least "special-cased" in the shell code. It looks as though this special case has a buggette in it. Practically speaking I guess it is inconsequential. Probably though PWD and OLDPWD should be read-only shell vars for robustness. I guess in the great scheme of things it doesn;t matter that much :) -- Regards Cliff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message