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

How to pass over ampersand to powershell from WSL? #2069

Closed
sunjoong opened this issue May 6, 2017 · 1 comment
Closed

How to pass over ampersand to powershell from WSL? #2069

sunjoong opened this issue May 6, 2017 · 1 comment

Comments

@sunjoong
Copy link

sunjoong commented May 6, 2017

  • Your Windows build number: (Type ver at a Windows Command Prompt)
    Microsoft Windows [Version 10.0.15063]

I tried to launch microsoft-edge with url having ampersand. I prepare a test url instead of my real url that's wanted to be launched.

In PowerShell, it will occur errors because of ampersand;

PS C:\Windows\System32\WindowsPowerShell\v1.0> pwd

Path
----
C:\Windows\System32\WindowsPowerShell\v1.0


PS C:\Windows\System32\WindowsPowerShell\v1.0> ./powershell.exe start microsoft-edge:"https://www.google.com/url?sa=t&url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FBashOnWindows%2Fissues&usg=AFQjCNHYJj1Y465rnV4VWzVcIVSF58cn9w"
At line:1 char:55
+ { start microsoft-edge:https://www.google.com/url?sa=t&url=https%3A%2 ...
+                                                       ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quot
ation marks ("&") to pass it as part of a string.
At line:1 char:121
+ ... ttps%3A%2F%2Fgithub.com%2FMicrosoft%2FBashOnWindows%2Fissues&usg=AFQj ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quot
ation marks ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed

PS C:\Windows\System32\WindowsPowerShell\v1.0>

But, it can be solved by {} like this;

PS C:\Windows\System32\WindowsPowerShell\v1.0> ./powershell.exe { start microsoft-edge:"https://www.google.com/url?sa=t&url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FBashOnWindows%2Fissues&usg=AFQjCNHYJj1Y465rnV4VWzVcIVSF58cn9w" }
PS C:\Windows\System32\WindowsPowerShell\v1.0>

I tried to this in WSL but failed.

SUNJOONG-DESKTOP v1.0 # pwd
/mnt/c/Windows/System32/WindowsPowerShell/v1.0
SUNJOONG-DESKTOP v1.0 # ./powershell.exe { start microsoft-edge:"https://www.google.com/url?sa=t&url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FBashOnWindows%2Fissues&usg=AFQjCNHYJj1Y465rnV4VWzVcIVSF58cn9w" }
At line:1 char:55
+ { start microsoft-edge:https://www.google.com/url?sa=t&url=https%3A%2 ...
+                                                       ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quot
ation marks ("&") to pass it as part of a string.
At line:1 char:121
+ ... ttps%3A%2F%2Fgithub.com%2FMicrosoft%2FBashOnWindows%2Fissues&usg=AFQj ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quot
ation marks ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed

SUNJOONG-DESKTOP v1.0 #

Same command with {}, but failed only in WSL. How can fix it?

@sunjoong
Copy link
Author

sunjoong commented May 6, 2017

Hmm.... I found that;

sunjoong@SUNJOONG-DESKTOP /mnt/c/Windows/System32/WindowsPowerShell/v1.0 $ ./powershell.exe start microsoft-edge:'\"https://www.google.com/url?sa=t&url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FBashOnWindows%2Fissues&usg=AFQjCNHYJj1Y465rnV4VWzVcIVSF58cn9w\"'
sunjoong@SUNJOONG-DESKTOP /mnt/c/Windows/System32/WindowsPowerShell/v1.0 $

The anser was '\"url\"', i.e., single-quot-mark+slash+double-quot-mark+url+slash+double-quot-mark+single-quot-mark.

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

No branches or pull requests

1 participant