Unable to pass & in an argument to a shell script started with Process.start #59604
Labels
area-dart-cli
Use area-dart-cli for issues related to the 'dart' command like tool.
triage-automation
See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
I'm trying to fix a bug where we mishandle some characters like
&
in user-provided arguments because of having to spawnflutter.bat
through a shell. There is a little info onProcess.start()
about this:The issue I'm having is that I can't find any way to escape a
&
that comes through correctly.Below is a script to reproduce the issue. It creates a temp folder with a space in the name, and then writes a simple
.bat
file that forwards all args to a Dart script (similar to whatflutter.bat
does). The Dart script it writes just prints all the arguments out to stdout. The test reads stdout and compares what's printed to what it sent as arguments to ensure they match.If I remove the
&
fromtestCharacters
, the test passes. If I add the&
then it fails because the last argument is truncated, and it tried to executeafter
:The
_escapeAndQuoteArg
function needs to escape&
in some way, but I've tried many combinations (including backslashes, the^
character and combinations of quoting/not quoting the args) (I'm assuming https://ss64.com/nt/syntax-esc.html is a reasonable source), but none of them work. Based on @derekxu16 comment at #50076 (comment) it's not clear to me if Dart is also trying to do some of this escaping.I'm not sure if this is a bug, or I'm doing it wrong. I'm hoping someone that understands the code in
createProcess
may be able to verify one way or the other.The text was updated successfully, but these errors were encountered: