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 onePS 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.
请先登录再写评论。
Result the same
Btw, my Terminal configs
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.