Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [zsh] Re: cd - and $OLDPWD, bug in the manual?



» On Sat, Mar 25, 2006 at 11:36PM -0800, Bart Schaefer wrote:

> The manual also says (note "Set" not "Used" here):
>
> Parameters Set By The Shell
>
> OLDPWD
>      The previous working directory.  This is set when the shell
>      initializes and whenever the directory changes.

Indeed I didn't read the OLDPWD entry. Thanks for pointing it out.

> The manual DOESN'T say that you can have any useful effect by
> assigning OLDPWD.  You can assign to PWD as well, but that doesn't
> cause a "cd" to magically occur.

I don't expect anything, except for the prompt, to automatically change
after an "export" without issuing any other command. (Whether that's
actually the case is beyond the point here.) I didn't expect this for
PWD nor for OLDPWD.

But I did expect "cd -" to change to the value of OLDPWD.

How did I come up with such a crazy, nonsensical idea?

By reading the manual, which *explicitly* states that this would
happen. No more, no less.

> The doc for "cd" could be marginally clearer if it said e.g. ...
>
>     If arg is `-', change to the previous directory, normally the value
>     of $OLDPWD.
>
> ... but would that have helped you?

Honestly, I'm sure it would.

Because it was the particular wording at the "cd" entry that got me into
trying to use the *value* of OLDPWD to influence "cd -".

IMHO this is not the case of being "marginally clearer" but about being
"technically accurate".

Regards,
Francisco



Messages sorted by: Reverse Date, Date, Thread, Author