Page 1 of 1

Passed variable (e.g., %1) are now quoted?

Posted: November 10th, 2008, 11:47 pm
by SizzlechestSA
I made a post-processing script a while back that uses %1.  I noticed ever since I upgraded to 0.4.5 that the variable passes the directory with quotes around it.  This breaks the script.  Is it possible to turn this off?  The scripts should be handling the quoting.

Re: Passed variable (e.g., %1) are now quoted?

Posted: November 11th, 2008, 3:15 am
by shypike
What was the previous release you used?

Re: Passed variable (e.g., %1) are now quoted?

Posted: November 11th, 2008, 7:35 am
by SizzlechestSA
shypike wrote: What was the previous release you used?
0.4.4

Re: Passed variable (e.g., %1) are now quoted?

Posted: November 11th, 2008, 12:00 pm
by shypike
There's no difference between 0.4.4 and 0.4.5 in this area.

Both versions put quotes around parameters that contain spaces, but
omit the quotes when no spaces are present.
This is standard behaviour of Windows + Python-libraries.

You can safely assume that you never need to put quotes around %x.

For Posix systems (Unix, Linux and OSX), the quotes are not present.

Re: Passed variable (e.g., %1) are now quoted?

Posted: November 12th, 2008, 11:39 pm
by SizzlechestSA
The problem with this is if you're writing a script that takes the variable and appends subfolders and/or filenames with spaces, it's not going to work.

I understand the quotes are not being put there by sabnzbd.  However, I think it would be a good idea to strip them (if they exist) before the variables are passed to the command line.  s/^"(.*)"$/\1/

Re: Passed variable (e.g., %1) are now quoted?

Posted: November 13th, 2008, 2:44 am
by shypike
We cannot strip them.
The problem with this is if you're writing a script that takes the variable and appends subfolders and/or filenames with spaces, it's not going to work.
Not true, try this in command prompt:

mkdir d:"with spaces"
mkdir d:"with spaces"\hello

Works fine.

Re: Passed variable (e.g., %1) are now quoted?

Posted: December 18th, 2008, 6:47 am
by shypike
Best trick to get rid of the quotes:

Code: Select all

set name=%1
set name=%name:"=%

Re: Passed variable (e.g., %1) are now quoted?

Posted: December 19th, 2008, 7:05 am
by doubledrat
to be clear, windows NEEDS the quotes on the command line, otherwise e.g. param 1 could become params 1,2,3,4 and 5 - it would be impossible to sort out.  This is not the fault of sabnzbd.

I can't remember an example, but you can sometimes get into trouble when you have multiple sets of quotes on some windows commands, so stripping the "" is by far the safest route to take.