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

refactor: detect current shell #219

Merged
merged 2 commits into from
Jun 18, 2023
Merged

Conversation

baszalmstra
Copy link
Collaborator

@baszalmstra baszalmstra commented Jun 17, 2023

Refactored the shell detection code. The following changes were made.

  • Added a function to detect the current shell based on the SHELL environment variable.
  • Added a function to detect the current shell based on the parent process name (behind a feature flag).
  • Removed the ShellEnum::detect_from_environment() method and moved implementation into ShellEnum::default().

To determine an appropriate current shell use:

let shell = ShellEnum::from_env() // First try to detect from $SHELL
    .or_else(ShellEnum::from_parent_process())  // Otherwise check the parent process
    .unwrap_or_default();  // Otherwise fall back to the os's default

Fix #216

@baszalmstra baszalmstra marked this pull request as ready for review June 17, 2023 19:48
@baszalmstra baszalmstra requested a review from wolfv June 17, 2023 19:48
@wolfv wolfv merged commit f5eb8fd into conda:main Jun 18, 2023
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.

Implement shell detection
2 participants