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

which broken in zsh #604

Closed
dhcmrlchtdj opened this issue Jan 1, 2015 · 9 comments
Closed

which broken in zsh #604

dhcmrlchtdj opened this issue Jan 1, 2015 · 9 comments
Labels
bugs Oh no, something's broken :-( shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh

Comments

@dhcmrlchtdj
Copy link
Contributor

nvm current and nvm ls can't detect current node version i choosen.

$ nvm use unstable
Now using node v0.11.14

$ nvm ls
    v0.11.14
->    system
unstable -> 0.11 (-> v0.11.14) (default)

$ nvm current
system

$ nvm which system
node: aliased to node --harmony

i found it caused by which.

i use zsh and alias node to node --harmony.
but which in zsh can't work well with alias.

$ zsh --version
zsh 5.0.7 (x86_64-apple-darwin14.0.0)

$ which node
node: aliased to node --harmony

$ which which
which: shell built-in command

$ whence -p node
/usr/local/bin/node

can we use whence -p to instead of which in zsh?

@drkibitz
Copy link
Contributor

drkibitz commented Jan 1, 2015

Maybe another suggestion using same shell executable:

which -a node | grep "$NVM_DIR"

@ljharb
Copy link
Member

ljharb commented Jan 1, 2015

@dhcmrlchtdj How did you install nvm? Which nvm --version do you have?

It seems like you might have an alias in your profile of node to node --harmony - that's likely gumming up the works?

@drkibitz
Copy link
Contributor

drkibitz commented Jan 1, 2015

Maybe this is better:

which -a node | grep -e "/node$" -m 1

Find first match ending in "/node", which should be the the first node executable in PATH.

@drkibitz
Copy link
Contributor

drkibitz commented Jan 1, 2015

@ljharb That's what it is, I have the exact same environment, in zsh the which command shows output for aliases, while it outputs nothing in sh.

@dhcmrlchtdj
Copy link
Contributor Author

@ljharb
i source nvm manually.

$ grep 'nvm\|node' ~/.zshrc
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
alias node="node --harmony"

$ nvm --version
0.22.0

@drkibitz 👍

which -a node | grep -e "/node$" -m 1

work well both bash and zsh.

@ljharb
Copy link
Member

ljharb commented Jan 1, 2015

I think you need alias node="\node --harmony" otherwise you've created a circular reference.

@dhcmrlchtdj
Copy link
Contributor Author

will alias cause circular reference?

A Bash alias is essentially nothing more than a keyboard shortcut

and following commad maybe better

$ command which node
/usr/local/bin/node

@ljharb
Copy link
Member

ljharb commented Jan 1, 2015

I'm not sure I understand the proposed solution but I'll be happy to evaluate a PR for it.

@ljharb ljharb added shell: zsh bugs Oh no, something's broken :-( labels Jan 2, 2015
ljharb added a commit that referenced this issue Jan 2, 2015
@ljharb
Copy link
Member

ljharb commented Jan 2, 2015

Closed via #605.

@ljharb ljharb added the shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. label Feb 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs Oh no, something's broken :-( shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh
Projects
None yet
Development

No branches or pull requests

3 participants