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 opam env messages #3274

Closed
wants to merge 4 commits into from
Closed

Fix opam env messages #3274

wants to merge 4 commits into from

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Apr 2, 2018

This PR fixes the display of the eval $(opam env) messages. In particular:

  • opam init -a should recommend another shell syntax #2925 converted the eval `opam config env` message to eval $(opam config env). At this point, it was necessary to add a special case for csh which doesn't support that syntax.
  • OpamEnv.eval_string only ever guessed the shell from $SHELL even when --shell had been passed to opam.
  • opam init always displayed eval $(opam env) regardless of the shell, as did --help screens.

This PR:

  • Adds an extra case for `csh which uses backticks.
  • Extends OpamEnv.eval_string to have a shell parameter. This is quite an invasive change - in particular, it means that switch, install, pin, remove and reinstall commands now have a --shell parameter. I was quite haphazard about where ~shell got put... if you're happy with the idea of this change, this should be rationalised (i.e. should the argument always be named and where should it go in argument listed).
  • opam init now displays the correct command for the given shell.
  • The --help screens for the switch, config and env commands now display the command based on $SHELL (i.e. OpamStd.Sys.guess_shell_compat). It's possible to peek the --shell argument here, but even I think that having SHELL=bash opam config --shell=fish --help work correctly is more effort than is necessary 😉

@dra27 dra27 force-pushed the fix-opam-env-message branch 2 times, most recently from 5987c72 to b418f67 Compare April 2, 2018 17:59
It should always be possible to override the shell which opam reports
messages for. Add a parameter for the shell in OpamEnv.eval_string and
thread that resulting parameter through the libraries.

The install, pin, reinstall, remove and switch subcommands now all take
the --shell parameter as a result.

fixup
opam init knows what the shell is, so should use it, rather than
guessing eval $(opam env).
Change in 42913bc needed to split off
`csh as a separate shell.
Use $SHELL to customise the display of --help output when eval $(opam
config env) is referred to. --shell is ignored (for reasons of code
simplicity).
@dra27
Copy link
Member Author

dra27 commented Apr 2, 2018

Hmm, the CI golf going on here has revealed that ignore is perhaps used a little too liberally in the code base...

@AltGr
Copy link
Member

AltGr commented Apr 5, 2018

Thanks! I am not sure about adding a --shell parameter to switch, install, etc. though, esp. since it's only used to print an advisory message. Maybe it would be best to store the shell info (which should be given at init) in ~/.opam/config, in case shell detection fails ?

@AltGr
Copy link
Member

AltGr commented May 15, 2018

Does not merge anymore, what is the status of this ?

@AltGr AltGr added the PR: OUTDATED This PR might still have meaningful content, but is getting stale and might be closed label Mar 11, 2020
@dra27
Copy link
Member Author

dra27 commented Dec 21, 2020

This has been merged as the superior #4427!

@dra27 dra27 closed this Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: OUTDATED This PR might still have meaningful content, but is getting stale and might be closed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants