[Top][All Lists]

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

Problem with function cd in bash 4.0

From: Bernd Eggink
Subject: Problem with function cd in bash 4.0
Date: Mon, 23 Feb 2009 23:32:21 +0100
User-agent: Thunderbird (X11/20081209)

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.


Bernd Eggink

reply via email to

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