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

Re: `exec env -i OLDPWD=$OLDPWD zsh` doesn't work



Timothee Cour wrote on Fri, Jan 13, 2017 at 01:15:27 -0800:
> how do i exec while passing OLDPWD?

You could pass it under some other name:

    exec env -i MY_OLDPWD=$OLDPWD zsh

but it's probably easier to do:

    (cd -- "$OLDPWD" && exec env -i NEWPWD=... zsh)

and have the new zsh cd to $NEWPWD.

> related [but for bash]:
> http://unix.stackexchange.com/questions/242909/why-does-bash-clear-oldpwd-when-a-child-script-is-started
>  QUOTE: It seems reasonable to inherit OLDPWD if it names a directory, in
> the same way that the shell inherits PWD if it names the current directory,
> so we'll try that for the next bash version.

Observation: making this change would change the behaviour of `cd -` in
interactive subshells.

What's the use-case for this?



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