Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: inherit OLDPWD from environment variable
> On 20/07/2024 08:56 BST Franklin Yu <franklinyu@xxxxxxxxxxx> wrote:
> Good catch. Indeed Bash accepts empty value. Then it becomes
>
> diff --git a/Src/init.c b/Src/init.c
> index ec21521b1..092273228 100644
> --- a/Src/init.c
> +++ b/Src/init.c
> @@ -1245,7 +1245,9 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
> pwd = metafy(zgetcwd(), -1, META_DUP);
> }
>
> - oldpwd = ztrdup(pwd); /* initialize `OLDPWD' = `PWD' */
> + oldpwd = zgetenv("OLDPWD");
> + if (oldpwd == NULL)
> + oldpwd = ztrdup(pwd); /* initialize `OLDPWD' = `PWD' */
>
> inittyptab(); /* initialize the ztypes table */
> initlextabs(); /* initialize lexing tables */
>
Looks fine to me, I'll commit it assuming nobody comes up with any gotchas.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author