PowerShell quoting
Opened this issue · 5 comments
The --dry-run
output on Windows works in Command Prompt, but not PowerShell, because PowerShell gets weird about unquoted arguments with the dot (.) symbol. Should the Windows --dry-run
put double quotes around each argument?
OK, so I guess the solution is to:
- Replace all
'
symbols in each argument with''
to escape them. - Surround each argument with single quote (
'
) symbols.
This should cover all the quoting cases for PowerShell.
Of course, then the dry-run output won't work in Command Prompt anymore... but I'm not sure we can have it both ways. Not unless there is a way to check the type of the attached console.
Probably will be sufficient to check an environment variable like WT_SESSION
, which should be set for PowerShell, but typically unset for Command Prompt. See this SO answer for elaboration.
In my hands WT_SESSION
and WT_PROFILE_ID
are defined iff running in Windows Terminal, regardless of whether it's PowerShell or cmd.exe.
(I personally think it's okay to not support the cmd.exe case here.)
As of 749bc50, Jaunch on Windows now detects which type of prompt it was launched from. The C layer could then pass this information to the Kotlin layer, which could use it to emit the proper style of quoting. I'm a little torn on whether this is too magical, though; perhaps instead we should have some explicit flags controlling it like --dry-run=ps1
or --dry-run=cmd
or --dry-run=sh
? But I'm probably overthinking it.