Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] .cmd @echo off #68

Open
1 task done
cshorler opened this issue Jun 18, 2022 · 0 comments
Open
1 task done

[BUG] .cmd @echo off #68

cshorler opened this issue Jun 18, 2022 · 0 comments
Labels
Needs Triage needs an initial review

Comments

@cshorler
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

this is similar to what is raised here (never resolved):
npm/npm#19681

At a Windows command prompt running npm -v with npm@latest seems to hang.
Typing echo on brings back the prompt as described in the above bug.

This seems to contradict Microsoft documentation for @echo off, that remarks (to quote)
"If used in a batch file, echo on and echo off don't affect the setting at the command prompt."

I see this behaviour on Windows 10.

If I patch the npm.cmd file like this, it behaves well:

@SETLOCAL
@FOR /f "tokens=1,2,3 delims=. " %%G IN ('ECHO') DO @SET _echo=%%I
@ECHO off

GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start

CALL :find_dp0

IF EXIST "%dp0%\node.exe" (
  SET "_prog=%dp0%\node.exe"
) ELSE (
  SET "_prog=node"
  SET PATHEXT=%PATHEXT:;.JS;=;%
)

ENDLOCAL & (CALL) || TITLE %COMSPEC% & "%_prog%" "%dp0%\node_modules\npm\bin\npm-cli.js" %* & ECHO %_echo%

Expected Behavior

normal exit, no change to current prompt setting.

Steps To Reproduce

  1. Start cmd prompt
  2. Run npm -v at the prompt
  3. appears to hang, echo on fixes

Environment

  • npm: 8.12.2
  • Node: v16.14.2
  • OS: Windows
  • platform: Microsoft Windows [Version 10.0.19044.1645]
@cshorler cshorler added the Needs Triage needs an initial review label Jun 18, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Needs Triage needs an initial review
Projects
None yet
Development

No branches or pull requests

1 participant