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

Double tilde when manually entering filename for shell configuration #5801

Open
ElectreAAS opened this issue Jan 23, 2024 · 4 comments · May be fixed by #5803
Open

Double tilde when manually entering filename for shell configuration #5801

ElectreAAS opened this issue Jan 23, 2024 · 4 comments · May be fixed by #5803

Comments

@ElectreAAS
Copy link
Collaborator

Issue description

Running a reinit and giving it a path starting with a tidle ~ bugs out.

Details

> pwd
/home/me/foo
> opam init --reinit
[...]
Do you want opam to configure bash?
1. Yes, update ~/.profile
2. ...
3. ...
4. Specify another config file to update instead
> 4
Enter the name of the file to update:
  • If you enter a simple filename opam-thingy.sh, it asks to update ~/opam-thingy.sh
  • If it's a qualified path like /etc/foobar/opam-thingy.sh, it asks to update exactly that ✅
  • If it's a relative path like ./opam-thingy.sh, it expands the relative path: ~/foo/opam-thingy.sh
  • If it's a path starting with a tilde like ~/.camels/opam-thingy.sh, it doubles the tilde: ~/~/.camels/opam-thingy.sh
  • Bonus: if it's a path starting with "$HOME" it won't expand the variable: ~/'$HOME'/opam-thingy.sh. But really, who would do that.
@ElectreAAS
Copy link
Collaborator Author

I believe the problem comes from this call to Filename.is_implicit, which doesn't handle paths starting with ~

@kit-ty-kate
Copy link
Member

Thanks for the report. That sounds like a pretty straightforward bug indeed.
It looks to me fairly straightforward to fix too, do you want to have a go at it?

@kit-ty-kate
Copy link
Member

I would personally use OpamFilename.Dir.of_string which handles ~

@ElectreAAS
Copy link
Collaborator Author

Yeah I can try to solve it tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants