nvm icon indicating copy to clipboard operation
nvm copied to clipboard

nvm.sh - executing under ksh fails as local is missing. Remediation by using typeset instead

Open chris-day opened this issue 2 years ago • 3 comments

Operating system and version:

RHEL9, Ubuntu using ksh as the login shell

Remediation is to change the use of "local" for setting variables and replace with "typeset"

How did you install nvm?

As per the README

What steps did you perform?

What happened?

. $NVM_DIR/nvm.sh -ksh: .: line 4373: local: not found -ksh: .: line 4343: local: not found -ksh: .: line 4345: local: not found -ksh: .: line 4346: local: not found -ksh: .[1127]: local: not found -ksh: .[506]: local: not found -ksh: .[396]: local: not found -ksh: .[398]: local: not found -ksh: .[406]: local: not found -ksh: .[408]: local: not found -ksh: .[396]: local: not found -ksh: .[398]: local: not found -ksh: .[406]: local: not found -ksh: .[408]: local: not found -ksh: .[1133]: local: not found -ksh: .: line 2778: local: not found -ksh: .: line 2809: local: not found -ksh: .: line 2932: local: not found -ksh: .: line 2937: local: not found -ksh: .: line 2938: local: not found -ksh: .: line 3540: local: not found -ksh: .: line 3541: local: not found -ksh: .: line 3542: local: not found -ksh: .: line 3543: local: not found -ksh: .: line 3545: local: not found -ksh: .: line 3546: local: not found -ksh: .[2508]: local: not found -ksh: .[2510]: local: not found -ksh: .[576]: local: not found -ksh: .[578]: local: not found -ksh: .[589]: local: not found -ksh: .[1250]: local: not found -ksh: .[1252]: local: not found -ksh: .[1259]: local: not found -ksh: .[1261]: local: not found -ksh: .[1263]: local: not found -ksh: .[506]: local: not found -ksh: .[1265]: local: not found -ksh: .[506]: local: not found -ksh: .[1267]: local: not found -ksh: .[506]: local: not found -ksh: .[1209]: local: not found -ksh: .[1210]: local: not found -ksh: .[1150]: local: not found -ksh: .[1153]: local: not found -ksh: .[1155]: local: not found -ksh: .[1157]: local: not found -ksh: .[754]: local: not found -ksh: .[1240]: local: not found -ksh: .[1285]: local: not found -ksh: .[776]: local: not found -ksh: .[784]: local: not found -ksh: .[786]: local: not found -ksh: .[153]: local: not found -ksh: .[1873]: local: not found -ksh: .[1875]: local: not found -ksh: .: line 540: local: not found -ksh: .: line 542: local: not found -ksh: .: line 551: local: not found -ksh: .: line 552: local: not found -ksh: .[576]: local: not found -ksh: .[578]: local: not found -ksh: .[589]: local: not found -ksh: .[1250]: local: not found -ksh: .[1252]: local: not found -ksh: .[1259]: local: not found -ksh: .[1261]: local: not found -ksh: .[1263]: local: not found -ksh: .[506]: local: not found -ksh: .[1265]: local: not found -ksh: .[506]: local: not found -ksh: .[1267]: local: not found -ksh: .[506]: local: not found -ksh: .[1209]: local: not found -ksh: .[1210]: local: not found -ksh: .[1150]: local: not found -ksh: .[1153]: local: not found -ksh: .[1155]: local: not found -ksh: .[1157]: local: not found -ksh: .[754]: local: not found -ksh: .[1240]: local: not found -ksh: .[1285]: local: not found -ksh: .[776]: local: not found -ksh: .[784]: local: not found -ksh: .[786]: local: not found -ksh: .[153]: local: not found -ksh: .[1873]: local: not found -ksh: .[1875]: local: not found -ksh: .: line 555: local: not found -ksh: .: line 153: local: not found -ksh: .[1873]: local: not found -ksh: .[1875]: local: not found -ksh: .: line 3624: local: not found -ksh: .[525]: local: not found -ksh: .[506]: local: not found -ksh: .: line 3645: local: not found -ksh: .: line 3655: local: not found -ksh: .: line 2550: local: not found -ksh: .: line 2559: local: not found -ksh: .: line 2561: local: not found -ksh: .: line 2578: local: not found -ksh: .[1873]: local: not found -ksh: .[1875]: local: not found -ksh: .: line 2587: local: not found -ksh: .: line 2615: local: not found -ksh: .: line 2541: local: not found -ksh: .: line 2629: local: not found -ksh: .: line 2541: local: not found -ksh: .: line 2643: local: not found -ksh: .: line 2541: local: not found -ksh: .: line 2657: local: not found -ksh: .[419]: local: not found -ksh: .: line 2541: local: not found

What did you expect to happen?

dot-in of $NVM executes without error

Is there anything in any of your profile files that modifies the PATH?


chris-day avatar May 20 '23 08:05 chris-day

I believe all these errors can be ignored and nvm will continue to work in ksh as-is.

The problem with using typeset is that it doesn’t work on all the other supported shells. If you can suggest a simple way to define a local variable that will work then I’m open to it - this is the reason ksh hasn’t been tested on nvm’s CI for a long time.

ljharb avatar May 20 '23 14:05 ljharb

What about testing using "command -v local" and "command -v typeset"? Whichever returns true, you would use as an alias to define a local variable.

chris-day avatar May 22 '23 09:05 chris-day

Whatever pattern we use would have to be repeated hundreds of times. What would that one look like?

ljharb avatar May 22 '23 14:05 ljharb