[gnu.bash.bug] cd in bash 0.99

andy@CSVAX.CALTECH.EDU (Andy Fyfe) (06/16/89)

It's permitted to put multiple /'s between components in a path name
(and something I tend to do since file completion adds then to the end
of directories and I'm not yet used to that).  Cd, with "..", however,
get's confused by this.
	$ cd /usr/local//src
	$ pwd
	/usr/local/src
	$ cd ../..
	$ pwd
	/usr/local

chet@kiwi.CWRU.EDU (Chet Ramey) (06/17/89)

In article <8906161251.AA04266@csvax.caltech.edu> andy@CSVAX.CALTECH.EDU (Andy Fyfe) writes:
>It's permitted to put multiple /'s between components in a path name
>Cd, with "..", however, get's confused by this.
>	$ cd /usr/local//src
>	$ pwd
>	/usr/local/src
>	$ cd ../..
>	$ pwd
>	/usr/local

Here's a quick look at what happens after I fix it; a one-line diff for
general.c follows (note that I have aliased pwd to "echo $PWD"; this
makes no difference).

cwns5$ echo $SHLVL
2
cwns5$ cd /usr/homes/chet/src/Shells/bash////Rt-AOS/
cwns5$ pwd
/usr/homes/chet/src/Shells/bash////Rt-AOS
cwns5$ cd ../..
cwns5$ pwd
/usr/homes/chet/src/Shells/bash//
cwns5$ cd Rt-AOS/
cwns5$ ./bash
cwns5$ echo $SHLVL
3
cwns5$ cd /usr/homes/chet/src/Shells/bash////Rt-AOS/
cwns5$ pwd
/usr/homes/chet/src/Shells/bash////Rt-AOS
cwns5$ cd ../..
cwns5$ pwd
/usr/homes/chet/src/Shells
cwns5$ 

Here's the fix (your line numbers may vary; I've made other changes):

*** bash-0.99/general.c	Wed May 24 21:16:07 1989
--- src-0.99/general.c	Fri Jun 16 15:22:59 1989
***************
*** 293,297
    while (n--)
      {
!       if (*p == '/')
  	p--;
  

--- 293,297 -----
    while (n--)
      {
!       while (*p == '/')	/* skip multiple occurrences of '/' */
  	p--;
  

Chet Ramey     Network Services Group, CWRU    chet@cwjcc.INS.CWRU.Edu

"The flagon with the dragon has the potion with the poison;
	the vessel with the pestle holds the brew that is true!"