bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with function cd in bash 4.0


From: Chet Ramey
Subject: Re: Problem with function cd in bash 4.0
Date: Mon, 23 Feb 2009 23:02:56 -0500
User-agent: Thunderbird 2.0.0.19 (Macintosh/20081209)

Bernd Eggink wrote:
> I normally wrap the builtin cd into a function cd, which does some
> additional things and then calls the builtin. Example:
> 
>    function cd
>    {
>     local list=$(echo *.bui)
>     # ...
>         builtin cd "$1"
>    }
> 
> I have a PS1 like this:
> 
>    PS1="\\w \$ "
> 
> With bash 3, this worked well; cd-ing into a directory changed the
> prompt immediately. With bash 4, however, the prompt keeps unchanged
> after a call to cd and only gets adjusted after the _next_ command. I
> noticed that this depends on a subshell being used in the function.
> Without that, it behaves as before.
> 
> Is that a bug? I can get the intended behaviour by putting
> 
>    eval "PS1='$PS1'"
> 
> at the end of the function, but that's a rather ugly workaround.

Yep, it's a bug.  Try the attached patch; it works for me.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.0/parse.y 2009-01-08 08:29:12.000000000 -0500
--- parse.y     2009-02-23 22:40:55.000000000 -0500
***************
*** 1616,1623 ****
    int *ret;
  
!   ret = (int *)xmalloc (3 * sizeof (int));
    ret[0] = last_read_token;
    ret[1] = token_before_that;
    ret[2] = two_tokens_ago;
    return ret;
  }
--- 1616,1624 ----
    int *ret;
  
!   ret = (int *)xmalloc (4 * sizeof (int));
    ret[0] = last_read_token;
    ret[1] = token_before_that;
    ret[2] = two_tokens_ago;
+   ret[3] = current_token;
    return ret;
  }
***************
*** 1632,1635 ****
--- 1633,1637 ----
    token_before_that = ts[1];
    two_tokens_ago = ts[2];
+   current_token = ts[3];
  }
  

reply via email to

[Prev in Thread] Current Thread [Next in Thread]