Page 1 of 1

Extracting does not always work

Posted: Sat Jan 09, 2010 5:37 pm
by lenwar
Hi,

I noticed that extracting does not always work properly. This happens when the downloaded (for example) .rar files have spaces in them. The files to be extracted should get " along with them.

So:

unrar -x "totally legal thing I downloaded.rar"
in stead of
unrar x totally legal thing I downloaded.rar


The unrar command under Linux doesn't like it that way. (it'll only see the "totally" part of the file)
I'm using 1.2.0 beta5, but earlier beta's had the same thing.



Cheers,
Lennard

Re: Extracting does not always work

Posted: Wed Jan 13, 2010 1:41 am
by phorane
Actually it is normal, it is the way the command line is analyzed by the console before the system really run the command "unrar":
On a command line arguments are separated by spaces, thus
unrar x totally legal thing I downloaded.rar
is analyzed as the command unrar called with 6 arguments, the first being totally".

To manage file with space in their name: or you use double quote as you said, or you escace the space character (that is a special character as others) with a backslash:
unrar x totally\ legal\ thing\ I\ downloaded.rar
If you use the autocompletion in the console (using the tab key) the backslash may be added automatically (this is the case for me)

I thing using the backslash is better because quote character are also special character and you can have some surprises if you do not really know how bash (or sh, csh...) works. As example double quotes (") and single quotes (') (that may work in this case) have not the same meaning.

Notice that if you have other special character in the name of your file you have to escape it also. It is the case for the double quote character and the backslash character itself.
For example the file
try\this"exa mple.rar
will be unrar with the command
unrar x try\\this\"exa\ mple.rar


But maybe you may use a graphical interface to decompress your files...

Re: Extracting does not always work

Posted: Sat Jan 16, 2010 7:14 am
by lenwar
(I'm aware why it fails, but thanks for explaining to the rest :P)

You have a good point:
Escaping would be a better solution, cross-shell wise, which could be accomplished use the python escape() escape command, but hey... I'm not a code (just an admin) so that's just how I would fix it for my own scripts.