Quoting Hell - the never-ending story

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
highend
Posts: 14993
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Quoting Hell - the never-ending story

Post by highend »

Ofc this works with:
C:\Temp\Code_Blue_r955-5.1.1 hammerhead.zip

as well, since ""<curitem>"" is correctly quoted.
One of my scripts helped you out? Please donate via Paypal

Stef123

Re: Quoting Hell - the never-ending story

Post by Stef123 »

Since I don't have 7z here atm, I tested it with my other scenario - from here
http://www.xyplorer.com/xyfc/viewtopic. ... 8&start=30
and BINGO - you are right, it works. :ball: Can't tell you what went wrong last time, but I will definitely check up on it later this week with the 7z stuff.

I like your solution better than mine, it contains less quotes :tup:
So for the record - this is indeed the way to go:

Code: Select all

runret("""cmd"" /c """"D:\Folder\SomeProgram.exe"" t ""<curitem>""""");
I wonder if I could turn this into a catch-all quoting rule? To replace my old, rather complicated one? Need to test whether the inside quadruple quote-frames will make a difference in other cases, but probably not. I am confident this will work across scenarios, runret or not.

GREAT. :appl: Many thanks, Ulf. You once again pulled it off. :beer:

highend
Posts: 14993
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Quoting Hell - the never-ending story

Post by highend »

I wonder if I could turn this into a catch-all quoting rule?
Should work, as long as one command / application calls another app.
I am confident this will work across scenarios, runret or not.
This isn't bound to any specific command. Sc run, open and openwith work with the same quoting "rules"...
One of my scripts helped you out? Please donate via Paypal

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Quoting Hell - the never-ending story

Post by TheQwerty »

If you can make the script multiple lines (and if not then you should make that your first priority) then save yourself some headaches and use a HEREDOC!

Code: Select all

runret(<<<HEREDOC
"cmd" /c ""D:\Folder\SomeProgram.exe" t "<curitem>""
HEREDOC
 );
Is the quoting still tricky? Sure, but you no longer have to deal with XY's escaping doubling up the quotes and it is much easier to understand how that relates to what you'd type into the Window's Run dialog or a command prompt.

Save the quotes - use a HEREDOC!

Stef123

Re: Quoting Hell - the never-ending story

Post by Stef123 »

Thanks TheQwerty,
it's a catch22, a choice between fire and brimstone. Burned myself repeatedly with Heredoc. Trailing spaces are to blame, a completely different syntax issue, and yet just as tricky to track down. Re-introduced them again and again by pasting snippets of code from external editors (trailing-space aware) into XY's SC testing environment.

Anyway, I hope I got it figured out by now. Both issues, quotes and trailing spaces.

admin
Site Admin
Posts: 66631
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Quoting Hell - the never-ending story

Post by admin »

I mentioned it countless times before but not yet in this thread I think: there is no "Quoting Hell" here, at least not hellisher as in every other programming language in the world. This is the daily bread and butter for every programmer under the sun, and really: it's one of the easiest parts of programming. Hell is elsewhere.

Stef123

Re: Quoting Hell - the never-ending story

Post by Stef123 »

Understood.
And not trying to convince you to change anything, nor do I intend to keep bitching about it. Was just responding to the alternate suggestion.

The reason it feels like hell to me - I am NOT a programmer. From my very limited experience (Office macros etc), scripting is - usually - much easier than full-fledged programming. Not the same thing. Just looking at say, AHK code, is a walk in the park compared to the equivalent version in SC. But again, no complaints, just my observation as a non-programmer who erroneously assumed he could easily use SC to construct a quick cmd-call WITHOUT knowing about all those intricacies. I've never come across """triple quotes""" anywhere else.

admin
Site Admin
Posts: 66631
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Quoting Hell - the never-ending story

Post by admin »

Well, you started it. You are becoming a programmer. Per aspera ad astra...

Post Reply