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] install.sh: install looks for .zshenv #3365

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrdomino
Copy link

A zsh user may have set ZDOTDIR to something other than $HOME, in which case the profile and rc files will not be located under $HOME. But unless the system zshenv has done something unusual, it is usually a safe bet that there will be a $HOME/.zshenv that, if nothing else, will be setting up ZDOTDIR.

A zsh user may have set `ZDOTDIR` to something other than `$HOME`, in which case the profile and rc files will not be located under `$HOME`. But unless the system `zshenv` has done something unusual, it is usually a safe bet that there will be a `$HOME/.zshenv` that, if nothing else, will be setting up `ZDOTDIR`.
@ljharb ljharb added shell: zsh feature requests I want a new feature in nvm! installing nvm: profile detection Issues with nvm's own install script, related to figuring out the right profile file. labels May 30, 2024
@ljharb
Copy link
Member

ljharb commented May 30, 2024

Thanks, I didn't know any of this about zsh.

Is there a way we can add some tests to cover this functionality?

@ljharb ljharb force-pushed the master branch 2 times, most recently from c6cfc3a to c20db2a Compare June 10, 2024 18:13
@mrdomino
Copy link
Author

Unfortunately, I have a lot on my plate right now. (It took until now to get to this email in my inbox, for example...)

A full integration test would probably just run the install script and then check that ~/.zshenv was modified if it was present.

Alternatively, if you wanted to get fancy, you could say something like:

#!/bin/sh
touch ~/.zshenv
ZDOTDIR=$(mktemp -d)
trap 'rmdir "$ZDOTDIR"' EXIT
zsh -c 'whence nvm >/dev/null 2>&1'
exitcode=$?
if [ $exitcode -eq 0 ]; then
  echo success
else
  echo failure
fi

And for the check for whether you need to modify the environment, you could just run $SHELL -c 'type nvm >/dev/null 2>&1' and similarly check the exit code (of the shell) - that should work for bash/zsh/ksh, I don't know about fish or tcsh...

But as far as I'm concerned all of that is "extra credit".

In any event this drive-by PR is presented "as is"; if it can be used, great, if not, shucks.

@ljharb ljharb added the pull request wanted This is a great way to contribute! Help us out :-D label Jul 26, 2024
@ljharb ljharb marked this pull request as draft July 26, 2024 23:39
@ljharb ljharb changed the title [fix] install looks for .zshenv [Fix] install.sh: install looks for .zshenv Jul 26, 2024
@Safay99

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature requests I want a new feature in nvm! installing nvm: profile detection Issues with nvm's own install script, related to figuring out the right profile file. pull request wanted This is a great way to contribute! Help us out :-D shell: zsh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants