Skip to content

.cmd scripts located in absolute paths containing spaces fail when run with arguments that trigger path conversion #319

@claritystorm

Description

@claritystorm

Description

.cmd scripts located in absolute paths containing spaces fail when run with arguments that trigger path conversion (e.g., "hello world" or "").

This affects tools like C:\Program Files\nodejs\npm.cmd with --prefix "C:\Users\Example User". A workaround is to call npm directly (without the .cmd extension) but this does not work when other tools call npm.cmd by default. Another workaround is to install Node.js through MSYS2 though this conflicts with nvm, which is not available as an MSYS2 package.

Reproduction

  1. Create C:\Program Files\test\test.cmd as follows:
@echo off
echo %1
  1. Run the following from an MSYS2 shell:
cd "C:\Program Files\test"
./test.cmd "hello world"

Expected

hello world

Actual

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions