Skip to content
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

Check if OLDPWD variable is overriden while executing 'cd -' #441

Merged
merged 2 commits into from
Mar 21, 2018
Merged

Check if OLDPWD variable is overriden while executing 'cd -' #441

merged 2 commits into from
Mar 21, 2018

Conversation

siteshwar
Copy link
Contributor

Resolves: #8

ksh does not check if OLDPWD variable is overriden while going to
previous directory through 'cd -'. For e.g.

OLDPWD=/bin ksh -c 'OLDPWD=/tmp cd -'

takes to '/bin' directory.

This commit fixes it.

Resolves: #8
@@ -896,6 +896,8 @@ else
err_exit 'cannot cd to ~{fd} when fd is /dev'
fi

mkdir $tmp/oldpwd
[[ $(OLDPWD="$tmp/oldpwd" cd -) == "$tmp/oldpwd" ]] || err_exit "cd - does not recognize overriden OLDPWD variable"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for adding a test. However, the wording of the error isn't quite correct. In fact, it's probably worth adding a related test:

cd /
OLDPWD=$tmp/oldpwd
cd -
[[ $PWD == "$tmp/oldpwd" ]] || err_exit "cd - does not recognize overridden OLDPWD variable"

That's because overriding OLDPWD does work but not if done by creating a new env context. The above test should pass without this fix.

Also, s/overriden/overridden/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the test case that you suggested.

@krader1961
Copy link
Contributor

LGTM

Add test cases to check if overriden OLDPWD variable is recognized while
executing 'cd -'.

Related: #8
@siteshwar siteshwar merged commit 14604f5 into att:master Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants