Skip to content

recipe execute fail if there is a space character in windows user name #4397

Closed as not planned
@williamlai

Description

@williamlai

In platform.txt I add recipe for building my own image:

recipe.objcopy.hex.cmd=my_img.bat
recipe.objcopy.hex.pattern="{runtime.tools.mytool.path}/{recipe.objcopy.hex.cmd}" "{build.path}\application.axf"

In a user name "foo bar" under windows, the whole command line like this when verbose enabled:

"C:\Users\foo bar\AppData\Local\Arduino15\packages\arduino\tools\mytool\1.0.2\my_img.bat" "C:\Users\foo bar\AppData\Local\Temp\buildfc17b6afbe0bd59b0e46992e10640eb5.tmp\application.axf"

And it execute fail with message:

'C:\Users\foo' is not internal or external command

So I trace source code of arduino-core, and find this code is specious in method exec() in Compiler.java

CommandLine commandLine = new DoubleQuotedArgumentsOnWindowsCommandLine(command[0]);

The class DoubleQuotedArgumentsOnWindowsCommandLine is not actually "double quoted" command[0]. It only passes the argument to super class CommandLine and the constructor of CommandLine also not adds double quotes. So the actually command executed is

C:\Users\foo bar\AppData\Local\Arduino15\packages\arduino\tools\mytool\1.0.2\my_img.bat "C:\Users\foo bar\AppData\Local\Temp\buildfc17b6afbe0bd59b0e46992e10640eb5.tmp\application.axf"

So it seems it needs add double quoted somewhere in the compile process.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions