diff --git a/NEWS b/NEWS index 1441be6c0189..4ed4f4314158 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ Any uppercase BUG_* names are modernish shell bug IDs. 2021-12-28: +- Fixed a bug that caused CDPATH to continue working after unsetting it. + - Added three options to the ulimit builtin with the same names and functionality as in Bash: - 'ulimit -k' sets the maximum number of kqueues. diff --git a/src/cmd/ksh93/bltins/cd_pwd.c b/src/cmd/ksh93/bltins/cd_pwd.c index e7ab960fcdb8..5e82d579bebf 100644 --- a/src/cmd/ksh93/bltins/cd_pwd.c +++ b/src/cmd/ksh93/bltins/cd_pwd.c @@ -140,7 +140,7 @@ int b_cd(int argc, char *argv[],Shbltin_t *context) && !(dir[0]=='.' && (dir[1]=='/' || dir[1]==0)) && !(dir[0]=='.' && dir[1]=='.' && (dir[2]=='/' || dir[2]==0))) { - if(!(cdpath = (Pathcomp_t*)shp->cdpathlist) && (dp=sh_scoped(shp,CDPNOD)->nvalue.cp)) + if((dp=sh_scoped(&sh,CDPNOD)->nvalue.cp) && !(cdpath = (Pathcomp_t*)shp->cdpathlist)) { if(cdpath=path_addpath(shp,(Pathcomp_t*)0,dp,PATH_CDPATH)) { diff --git a/src/cmd/ksh93/tests/variables.sh b/src/cmd/ksh93/tests/variables.sh index cade47cf60b2..198cfa828e2d 100755 --- a/src/cmd/ksh93/tests/variables.sh +++ b/src/cmd/ksh93/tests/variables.sh @@ -305,6 +305,8 @@ x=$(cd ${tmp#/}) if [[ $x != $tmp ]] then err_exit "CDPATH ${tmp#/} does not display new directory" fi +unset CDPATH +cd "${tmp#/}" >/dev/null 2>&1 && err_exit "CDPATH not deactivated after unset" cd "$tmp" || exit TMOUT=100 (TMOUT=20)