Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

question: defining function based on alias `cd' #32

Closed
rosskevin opened this issue Sep 11, 2017 · 12 comments
Closed

question: defining function based on alias `cd' #32

rosskevin opened this issue Sep 11, 2017 · 12 comments
Labels

Comments

@rosskevin
Copy link
Contributor

I just updated everything on OSX, zsh is now 5.4.1_1 and I'm suddenly getting:

/Users/kross/.zshrc:127: defining function based on alias `cd'
/Users/kross/.zshrc:127: parse error near `()'

in my .zshrc on line

cd () { builtin cd "$@" && chpwd; }

I'm sure it is a local problem, but I know little about zsh scripting etc. Any thoughts?

@Kikobeats
Copy link
Owner

Kikobeats commented Sep 11, 2017

I have the script inside .extra::

chpwd () {
  local PKG=$PWD/package.json
  if [ -f "$PKG" ] && [ "$NODENGINE_LAST_DIR" != "$PWD" ]; then
    nodengine
    # printf "\033[36m%s\033[0m \033[90m%s\033[0m\n" "nodengine" "$(node --version)"
    NODENGINE_LAST_DIR=$PWD
  fi
}

@rosskevin
Copy link
Contributor Author

I tried that, but it made no difference, same exact error.

@rosskevin
Copy link
Contributor Author

This appears to be some kind of conflict with the latest rvm. Another developer just performed all the latest updates (brew, rvm, ruby) and he encountered the same thing.

I see rvm uses the same aliasing kind of mechanism. I'm wondering if you cannot alias an alias...?

@Kikobeats
Copy link
Owner

oh man, rvm is a mistake. use n, seriously: https://www.npmjs.com/package/n

@rosskevin
Copy link
Contributor Author

I use n for Node, rvm for Ruby. n doesn't manage rubies.

@Kikobeats
Copy link
Owner

oh sorry, I understood nvm.

I have rvm as well:

rvm --version
rvm 1.29.2 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]

@rosskevin
Copy link
Contributor Author

We are on rvm 1.29.3 (latest stable)

@Kikobeats
Copy link
Owner

I close this because is not highly related with nodengine issue, but feel free to comment

@rosskevin
Copy link
Contributor Author

rosskevin commented Sep 15, 2017

Well, not sure what to say. It's an issue, verified on two machines with the recommended integration from the README.

So essentially, nodengine doesn't work because it never gets triggered. I agree this could be an environmental issue, but it could be more prevalent with others as we just did blanket brew/Ruby/rvm updates here.

I actually expect others to start bumping into it.

@Kikobeats
Copy link
Owner

not sure why rvm is related with this.

If you execute nodengine, it works?

Then is a problem related with your shell scripts

@rosskevin
Copy link
Contributor Author

rosskevin commented Sep 15, 2017

Yes, direct execution of nodengine has no problems.

The shell hooks are what makes nodengine useful in my opinion. Otherwise I'm more likely to just type n + arrow + return instead of nodengine when I change directories.

Also, these same scripts have been working for at least a year, the ones copied from the README here. So agreed, environmental change, but the scripts from here are the only things breaking with updated software.

@rosskevin
Copy link
Contributor Author

Finally I found it. I knew it! Error prone syntax, so this is officially a bug. Credit to ohmyzsh/ohmyzsh#6237 (comment)

I'll PR the readme change that works.

rosskevin added a commit to rosskevin/nodengine that referenced this issue Sep 15, 2017
The old syntax started erroring with zsh 5.4.1.  This new change is confirmed working.  Note that the function used does need to be declared (it seems) before the others.
Kikobeats added a commit that referenced this issue Sep 15, 2017
Fixes #32 - error prone zsh syntax
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants