Skip to content

Filename.quote_command on Win32 does not handle forward slashes in program path correctly #13415

@nojb

Description

@nojb

Forward slashes in the "program" argument of Filename.quote_command should be taken as a reason to quote the program path. Otherwise, cmd.exe interprets forward slashes as introducing a flag (eg foo/x is interpreted as foo /x). The issue is exhibited by the following interaction:

$ rlwrap ocaml
OCaml version 4.14.2+LEXIFI
Enter #help;; for help.

# print_endline (Filename.quote_command "a/b.exe" ["x"]);;
"a/b.exe ^"x^""
- : unit = ()
# Sys.command (Filename.quote_command "a/b.exe" ["x"]);;
'a' n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
- : int = 1
#

Here a/b.exe should be quoted (surrounded by double quotes) but it isn't, so cmd.exe think the program name path is a instead of a/b.exe.

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