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

$dirprev variable scope is not honored using cd #5797

Closed
lucas-santoni opened this issue Apr 7, 2019 · 2 comments
Closed

$dirprev variable scope is not honored using cd #5797

lucas-santoni opened this issue Apr 7, 2019 · 2 comments

Comments

@lucas-santoni
Copy link
Contributor

@lucas-santoni lucas-santoni commented Apr 7, 2019

Using fish, version 3.0.2, on macOS Mojave 10.14.4.

I would like to share my cd / cdh history between fish instances.

Quoting man cdh:

Note that the cd command limits directory history to the 25 most recently visited
directories. The history is stored in the $dirprev and $dirnext variables which
this command manipulates. **If you make those universal variables your cd history is
shared among all fish instances.**

Taking a look at the share/functions/cd.fish file, we can see that the $dirprev variable is set at the global scope, shadowing the universal variable of the same name.

Maybe we can fix this by honoring $dirprev scope if its set universally? I opened #5796 to this effect.

@0ion9
Copy link
Contributor

@0ion9 0ion9 commented Apr 7, 2019

Is there a reason we can't just unconditionally honor any existing scope of dirprev?
As in the following:

set -q dirprev
and set -a dirprev $previous
or set -g -a dirprev $previous

Edit: never mind, read the context. Don't quite get why it's being set locally there in the earlier lines... it doesn't appear that setting it locally would impact the following lines, either in the unmodified version or in your PR.

Does make me wonder about whether something like set -qgU should be legal, in order to be able to say 'if it's set globally or universally, don't change its scope when appending'.

@lucas-santoni
Copy link
Contributor Author

@lucas-santoni lucas-santoni commented Apr 13, 2019

Fixed by #5796 ! ;)

@zanchey zanchey added this to the fish 3.1.0 milestone Apr 23, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants