Can't execute bash script in the PowerShell Terminal using Run Configuration

已回答

Just tried to run my bash script in the IntelliJ IDEA 2024.3.4.1 PowerShell Terminal using Run Configuration.
This is my Run Configuration

But when I click the Run button I get the following error:

PS C:\Program Files\Git\bin> "C:\Program Files\Git\bin\bash.exe" C:\Users\Me&Co\AppData\Roaming\JetBrains\IntelliJIdea2024.3\scratches\my_test_script.sh
At line:1 char:37
+ "C:\Program Files\Git\bin\bash.exe" C:\Users\Me&Co\AppData\Roam ...
+                                     ~~~~~~~~~~~~
Unexpected token 'C:\Users\Me' in expression or statement.
At line:1 char:48
+ "C:\Program Files\Git\bin\bash.exe" C:\Users\Me&Co\AppData\Roam ...
+                                                ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

PS: From within the PowerShell Terminal I can run the following command without any issues:
PS C:\Program Files\Git\bin> .\bash.exe  "C:\Users\Me&Co\AppData\Roaming\JetBrains\IntelliJIdea2024.3\scratches\my_test_script.sh"
 or this one
PS C:\Program Files\Git\bin> & "C:\Program Files\Git\bin\bash.exe" "C:\Users\Me&Co\AppData\Roaming\JetBrains\IntelliJIdea2024.3\scratches\my_test_script.sh"

And Run Configuration works well when I uncheck the "Execute in the terminal", but I need to run it in the Terminal.
 

 

0
I can't reproduce the same with Windows local powershell (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe), could you please check the same?
0
PS C:\Windows\System32\WindowsPowerShell\v1.0> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\Users\Me&Co\AppData\Roaming\JetBrains\IntelliJIdea2024.3\scratches\port-forward-ui.sh
At line:1 char:70
+ ... stem32\WindowsPowerShell\v1.0\powershell.exe C:\Users\Me&Co\App ...
+                                                             ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed

Result the same

Btw, my Terminal configs

0
It could be specific to the content of the script, could you please upload a sample script to https://uploads.jetbrains.com/ and share the upload ID?
0

It's not related to the script content. The issue is how IDEA “prints” the script path to the Powershell console.
It should add the path to the script surrounded with quotes, but doesn't do it.
And as you may see - in my case the path to the script contains symbols that must be escaped in the Powershell console.
 

0

请先登录再写评论。