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

autoenv_leave: Only match prefix on path boundaries #238

Merged
merged 2 commits into from
Jun 30, 2024
Merged

autoenv_leave: Only match prefix on path boundaries #238

merged 2 commits into from
Jun 30, 2024

Conversation

tomtseng
Copy link
Contributor

Suppose we cd from a/b to a/bz.

Expected behavior: Invoke `a/b/.env.leave.

Actual behavior prior to this commit: No env-leave is invoked.

The issue is that we are naively checking for string prefixes in autoenv_leave in order to determine whether one directory is an ancestor of another. This commit makes the checking slightly less naive by adding a trailing slash. This way, a/bz/ is not a prefix of /a/b/.

Suppose we `cd` from `a/b` to `a/bz`.

Expected behavior: Invoke `a/b/.env.leave.

Actual behavior prior to this commit: No env-leave is invoked.

The issue is that we are naively checking for string prefixes in
`autoenv_leave` in order to determine whether one directory is an
ancestor of another. This commit makes the checking slightly less naive.
activate.sh Outdated Show resolved Hide resolved
@hyperupcall
Copy link
Owner

hyperupcall commented Jun 30, 2024

Thanks for the fix! I updated the patch to use case so this fix is compatible with POSIX compliant shells (even if it makes it a bit more messy) and have added a test case to prevent the unlikely regression

@hyperupcall hyperupcall merged commit c3699a4 into hyperupcall:master Jun 30, 2024
2 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.

2 participants