It is currently April 16th, 2024, 4:14 pm

[(NOT A)BUG]Double Quotes and RunCommand Parameter

Report bugs with the Rainmeter application and suggest features.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

[(NOT A)BUG]Double Quotes and RunCommand Parameter

Post by death.crafter »

When reading the Parameter option in RunCommand, the double quotes used inside the the parameters are removed. The work around is using magic quotes.

But considering it's functionality, the quotes should not be removed, neither from start and end, nor from in-between.

Code: Select all

[RunCommand]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=echo "I need this displayed"
OutputType=ANSI
should display this:
Screenshot 2021-09-03 115926.png
and not this:
Screenshot 2021-09-03 120508.png
You do not have the required permissions to view the files attached to this post.
Last edited by death.crafter on September 3rd, 2021, 5:04 pm, edited 1 time in total.
from the Realm of Death
User avatar
SilverAzide
Rainmeter Sage
Posts: 2602
Joined: March 23rd, 2015, 5:26 pm

Re: [BUG] Double Quotes and RunCommand Parameter

Post by SilverAzide »

Is this really a quote "bug"? Something weird is happening, however, and I'm not sure it has anything to do with quotes.

The code you posted is working fine for me with respect to the quoting. But the strange thing is that output is not "Ineedthisdisplayed" as it appears to be in the debug log window. If you output to a file, it is actually this:
wth.png
What's up with all the CRLFs?!? Changing the parameter to Parameter=echo 'I need this displayed' works fine, but using double-quotes doesn't work no matter how magical you make them. I'm not sure why the results are different with RunCommand compared to typing that same command into an actual PS window.

:confused:
You do not have the required permissions to view the files attached to this post.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG] Double Quotes and RunCommand Parameter

Post by jsmorley »

SilverAzide wrote: September 3rd, 2021, 2:45 pm Is this really a quote "bug"? Something weird is happening, however, and I'm not sure it has anything to do with quotes.

The code you posted is working fine for me with respect to the quoting. But the strange thing is that output is not "Ineedthisdisplayed" as it appears to be in the debug log window. If you output to a file, it is actually this:
wth.png

What's up with all the CRLFs?!? Changing the parameter to Parameter=echo 'I need this displayed' works fine, but using double-quotes doesn't work no matter how magical you make them. I'm not sure why the results are different with RunCommand compared to typing that same command into an actual PS window.

:confused:
I'm not sure what is removing the double quotes. It shouldn't be Rainmeter or the RunCommand plugin, as quotes are only removed from any option value if they are both starting and ending quotes on the option. Not quite sure what is going on here.


1.png

2.png


Clearly PowerShell deals with the "echo" command (which is an alias in PowerShell anyway) differently than cmd.exe does.


3.png
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2602
Joined: March 23rd, 2015, 5:26 pm

Re: [BUG]Double Quotes and RunCommand Parameter

Post by SilverAzide »

This doesn't resolve the weirdness, but the following PS command works properly (instead of using echo):

Parameter=Write-Host "I need this displayed"

Write-Output does NOT work.... it is the same as echo.
Gadgets Wiki GitHub More Gadgets...
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [BUG] Double Quotes and RunCommand Parameter

Post by death.crafter »

SilverAzide wrote: September 3rd, 2021, 2:45 pm Is this really a quote "bug"? Something weird is happening, however, and I'm not sure it has anything to do with quotes.

The code you posted is working fine for me with respect to the quoting. But the strange thing is that output is not "Ineedthisdisplayed" as it appears to be in the debug log window. If you output to a file, it is actually this:
wth.png

What's up with all the CRLFs?!? Changing the parameter to Parameter=echo 'I need this displayed' works fine, but using double-quotes doesn't work no matter how magical you make them. I'm not sure why the results are different with RunCommand compared to typing that same command into an actual PS window.

:confused:
echo can take multiple parameters.

Parameter=echo "AA bb Cc" becomes, Parameter=echo AA bb Cc

The output in powershell for first is

Code: Select all

AA bb Cc
and for second is

Code: Select all

AA
bb
Cc
CRLF is Rainmeter's way of saying \r\n. Basically an return.

Hence the bug is, double quotes are being removed even if there is none at start.
from the Realm of Death
User avatar
SilverAzide
Rainmeter Sage
Posts: 2602
Joined: March 23rd, 2015, 5:26 pm

Re: [BUG] Double Quotes and RunCommand Parameter

Post by SilverAzide »

death.crafter wrote: September 3rd, 2021, 3:03 pm Hence the bug is, double quotes are being removed even if there is none at start.
Well, I don't think this has anything to do with Rainmeter. It is PowerShell that is interfering somehow in the quote handling, as jsmorley pointed out.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG]Double Quotes and RunCommand Parameter

Post by jsmorley »

Yeah, I think I would use Write-Host "I need this displayed" in PowerShell rather than echo "I need this displayed", which is really Write-Output "I need this displayed".
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [BUG] Double Quotes and RunCommand Parameter

Post by death.crafter »

SilverAzide wrote: September 3rd, 2021, 3:05 pm Well, I don't think this has anything to do with Rainmeter. It is PowerShell that is interfering somehow in the quote handling, as jsmorley pointed out.
Screenshot 2021-09-03 203801.png
Powershell is behaving correctly. Rainmeter isn't. Try Parameter=echo """"I need this displayed!""""
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [BUG]Double Quotes and RunCommand Parameter

Post by death.crafter »

jsmorley wrote: September 3rd, 2021, 3:09 pm Yeah, I think I would use Write-Host "I need this displayed" in PowerShell rather than echo "I need this displayed", which is really Write-Output "I need this displayed".
It's not about the output really. It's about the double quotes. echo was just a simple example to portray the thing.
from the Realm of Death
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG]Double Quotes and RunCommand Parameter

Post by jsmorley »

Feels to me like the issue must be with RunCommand.