Page 2 of 3
Re: [BUG] Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:14 pm
by SilverAzide
death.crafter wrote: ↑September 3rd, 2021, 3:09 pm
Screenshot 2021-09-03 203801.png
Powershell is behaving correctly. Rainmeter isn't. Try
Parameter=echo """"I need this displayed!""""
And so your explanation for why
Parameter=Write-Host "I need this displayed" works perfectly would be... what?
Re: [BUG] Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:16 pm
by death.crafter
SilverAzide wrote: ↑September 3rd, 2021, 3:14 pm
And so your explanation for why
Parameter=Write-Host "I need this displayed" works perfectly would be... what?
Screenshot 2021-09-03 204615.png
Re: [BUG]Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:20 pm
by jsmorley
There seems to be some issue with how echo aka Write-Output is being handled with RunCommand. I can't put my finger on it. It all works as expected in the PowerShell UI, but not with RunCommand. Write-Host seems to work fine, and is what I would use.
Re: [BUG]Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:27 pm
by death.crafter
jsmorley wrote: ↑September 3rd, 2021, 3:20 pm
There seems to be some issue with how echo aka Write-Output is being handled with RunCommand. I can't put my finger on it. It all works as expected in the PowerShell UI, but not with RunCommand.
It's not only echo or Write-Output.
Try
Parameter=(Get-ChildItem "C:\Program Files (x86)").Count
RunCommand is just stripping off the double quotes.
After some testing...
LMAO!!!
Try this
Code: Select all
[RunCommand]
Measure=Plugin
Plugin=RunCommand
Parameter=echo "I need this displayed!"
OutputType=ANSI
Re: [BUG]Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:30 pm
by jsmorley
death.crafter wrote: ↑September 3rd, 2021, 3:27 pm
It's not only echo or Write-Output.
Try
Parameter=(Get-ChildItem "C:\Program Files (x86)").Count
RunCommand is just stripping off the double quotes.
After some testing...
LMAO!!!
Try this
Code: Select all
[RunCommand]
Measure=Plugin
Plugin=RunCommand
Parameter=echo "I need this displayed!"
OutputType=ANSI
The output of cmd.exe is not ANSI...
Re: [BUG]Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:35 pm
by death.crafter
jsmorley wrote: ↑September 3rd, 2021, 3:30 pm
The output of cmd.exe is not ANSI...
Ahh I see. Yeah it works fine.
Then why do the quotes in powershell parameter get removed
Re: [BUG]Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:37 pm
by jsmorley
death.crafter wrote: ↑September 3rd, 2021, 3:35 pm
Ahh I see. Yeah it works fine.
Then why do the quotes in powershell parameter get removed
Well, that's the 64,000 dollar question isn't it... Seems like somehow the "interface" between RunCommand and PowerShell is stripping them out of the Parameter. Hard to say if this is a RunCommand issue exactly, or a PowerShell issue that is only manifested due to how we pass the command to it. I'm sure Brian will look into this, but at least for now, I would recommend using 'single quotes' instead of "double quotes" in parameters to PowerShell. Just like we recommend using single quotes in Lua scripts.
Re: [BUG]Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:43 pm
by death.crafter
jsmorley wrote: ↑September 3rd, 2021, 3:37 pm
Well, that's the 64,000 dollar question isn't it... Seems like somehow the "interface" between RunCommand and PowerShell is stripping them out of the Parameter. Hard to say if this is a RunCommand issue exactly, or a PowerShell issue that is only manifested due to how we pass the command to it. I'm sure Brian will look into this, but at least for now, I would recommend using 'single quotes' instead of "double quotes" in parameters to PowerShell. Just like we recommend using single quotes in Lua scripts.
Parameter=Write-Output
""""$('Can't be helped,'+' I guess!')"
"""
Re: [BUG]Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:44 pm
by death.crafter
Thanks a lot for looking in to this. Hope Brian finds a feasible solution.
Re: [BUG]Double Quotes and RunCommand Parameter
Posted: September 3rd, 2021, 3:46 pm
by jsmorley
death.crafter wrote: ↑September 3rd, 2021, 3:44 pm
Thanks a lot for looking in to this. Hope Brian finds a feasible solution.
He might, but to be honest I don't see any important distinction between single quotes that work, and double quotes that don't.
Code: Select all
[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Program=Powershell
Parameter=echo 'I need this displayed'
OutputType=ANSI
Parameter=echo 'I need this displayed'
Parameter=Write-Output 'I need this displayed'
Parameter=Write-Host 'I need this displayed'
All those work identically and equally well.
I could see this being an issue worth dealing with though, as this would be a problem:
Parameter=Write-Host 'I "need" this displayed'
That would need to be:
Parameter=Write-Host 'I \"need\" this displayed'
Seems like the interface between RunCommand and PowerShell just yaks up a hairball on "quotes".