Hi!
 
Does the patch below solve the problem?

Yes, it does. And it's a better solution than mine.

About the code. Why does it use `cd' -- I thought it mainly was for interactive use. However, I didn't want to change the code more than necessary.

    -- Anders