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

fix(elvish): before-chdir should assign to oldpwd upvalue #818

Merged
merged 1 commit into from
May 29, 2024

Conversation

alaviss
Copy link
Contributor

@alaviss alaviss commented May 17, 2024

elvish uses lexical scoping for closure capture, as such all oldpwd references within the script refers to the oldpwd defined at the top. However, before-chdir hook is trying to assign to oldpwd within the editor scope, which is not used by this script.

This manifested as a bug in which:

~
> mkdir -p /tmp/another

~
> z /tmp

/tmp
> z another

/tmp/another
> z -

~
> # The previous dir should be /tmp not ~!

Because the hook was updating a variable that was not used.

This PR fixes the hook so that before-chdir assign to the proper upvalue.

elvish uses lexical scoping for closure capture, as such all `oldpwd`
references within the script refers to the `oldpwd` defined at the top.
However, before-chdir hook is trying to assign to `oldpwd` within the
editor scope, which is not used by this script.

This manifested as a bug in which:

```
~
> mkdir -p /tmp/another

~
> z /tmp

/tmp
> z another

/tmp/another
> z -

~
> # The previous dir should be /tmp not ~!
```

Because the hook was updating a variable that was not used.

Fix the hook so that before-chdir assign to the proper upvalue.
@ajeetdsouza
Copy link
Owner

Thanks!

@ajeetdsouza ajeetdsouza merged commit 0dfe1c4 into ajeetdsouza:main May 29, 2024
4 checks passed
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.

None yet

2 participants