apposed / jaunch

Launch Programs 𝙔𝙤𝙪𝙧 Way! 🍔
The Unlicense
11 stars 2 forks source link

PowerShell quoting #33

Open ctrueden opened 9 months ago

ctrueden commented 9 months ago

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?

mkitti commented 9 months ago

xref: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.4

ctrueden commented 9 months ago

OK, so I guess the solution is to:

  1. Replace all ' symbols in each argument with '' to escape them.
  2. 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.

ctrueden commented 3 months ago

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.

marktsuchida commented 3 months ago

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.)