-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HOME=/dest cd
does not honour the HOME
environment
#602
Labels
bug
Something is not working
Comments
The fix is simple: there was a missing diff --git a/src/cmd/ksh93/bltins/cd_pwd.c b/src/cmd/ksh93/bltins/cd_pwd.c
index 977be2bcf..9a7d25fb8 100644
--- a/src/cmd/ksh93/bltins/cd_pwd.c
+++ b/src/cmd/ksh93/bltins/cd_pwd.c
@@ -107,7 +107,7 @@ int b_cd(int argc, char *argv[],Shbltin_t *context)
if(argc==2)
dir = sh_substitute(oldpwd,dir,argv[1]);
else if(!dir)
- dir = nv_getval(HOME);
+ dir = nv_getval(sh_scoped(HOME));
else if(*dir == '-' && dir[1]==0)
dir = nv_getval(opwdnod);
if(!dir || *dir==0) |
This didn't work either, and is also fixed by the patch above:
|
McDutchie
added a commit
that referenced
this issue
Feb 16, 2023
When using the default value ($HOME) in the absence of an argument, 'cd' incorrectly used the global scope of HOME regardless of local scope. Example reproducers: # HOME=/bin cd; pwd /root # Should be /bin $ function fn { typeset HOME=/tmp; cd; } $ fn $ pwd /Users/martijn # Should be /tmp src/cmd/ksh93/bltins/cd_pwd.c: b_cd(): - Add missing sh_scoped() call when retrieving the value of HOME. Thanks to @Earnestly for the report. Resolves: #602
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In ksh-community/ksh#19 (comment), @Earnestly wrote:
I agree this should work, and it's a bug that it doesn't.
cd
is a regular built-in command, so the preceding assignment toHOME
should be in effect whilecd
is executed.Confirmed in ksh 93u+ 2012-08-01 and in current ksh 93u+m.
The text was updated successfully, but these errors were encountered: