Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell quoting #33

Open
ctrueden opened this issue Feb 1, 2024 · 4 comments
Open

PowerShell quoting #33

ctrueden opened this issue Feb 1, 2024 · 4 comments

Comments

@ctrueden
Copy link
Member

ctrueden commented Feb 1, 2024

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?

@ctrueden
Copy link
Member Author

ctrueden commented Feb 2, 2024

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
Copy link
Member Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants