Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: inherit OLDPWD from environment variable
> On 21/07/2024 20:30 BST Peter Stephenson > Looks fine to me, I'll commit it assuming nobody comes up with any gotchas.
One correction.
diff --git a/Src/init.c b/Src/init.c
index ec21521b1..0aecb5db9 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1245,7 +1245,11 @@ 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' */
+ else
+ oldpwd = ztrdup(oldpwd);
inittyptab(); /* initialize the ztypes table */
initlextabs(); /* initialize lexing tables */
Messages sorted by:
Reverse Date,
Date,
Thread,
Author