Page 1 of 1

Filelist (@list.txt) quote escape

Posted: 2016-12-18T13:59:54-07:00
by q3cpma
Hello,
I have some trouble figuring the escape type needed in the following case:

Code: Select all

$ ls -1 --quoting-style=literal test*
test  "'.png
test.png
$ cat list.txt
'test  "'\''.png'
test.png
$ montage @list.txt out.png
montage: unable to open image `test  "': No such file or directory @ error/blob.c/OpenBlob/2705.
montage: no decode delegate for this image format `' @ error/constitute.c/ReadImage/504.
I've tried everything, (backlash escape, backlash + quotes) but I can't get it to work.

Using imagemagick 6.9.6 on Gentoo

Code: Select all

$ convert -version
Version: ImageMagick 6.9.6-6 Q16 x86_64 2016-12-03 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo fftw fontconfig freetype jng jp2 jpeg ltdl png rsvg tiff webp x zlib

Re: Filelist (@list.txt) quote escape

Posted: 2016-12-18T15:16:15-07:00
by snibgo
Your filename contains space, and a single-quote, and a double quote. It needs to be quoted, because of the space. But neither double nor single quotes can be used.

The @-file is not interpreted by the shell, so shell escapes won't help. I don't think IM has an escape mechanism.

A workaround is to rename files so they don't contain special characters.

Re: Filelist (@list.txt) quote escape

Posted: 2016-12-18T16:01:43-07:00
by q3cpma
So this is a bug?

Re: Filelist (@list.txt) quote escape

Posted: 2016-12-19T23:49:15-07:00
by anthony
Technically under unix filenames can even contain newline and return charactors!

The ONLY characters a filename can not have is slash '/' and null (character code 0). which is why find has a -print0 and xargs has a -0 form.

For ImageMagick. I am not certian what the limitations or even what the delimitors for a file list is. It may be returns or just whitespace, but judging from the error report it looks like it objected to the single quote (not the double).

Best solution around the 'bug' may be a temporary renaming method. as snibgo pointed out. That is what I would do because I would hate polluting the disk space with such horrible and awkward filenames anyway.

Re: Filelist (@list.txt) quote escape

Posted: 2016-12-20T01:40:45-07:00
by snibgo
IM objects to the space because, in that context, the delimiter is whitespace. Remove the space and it works fine.

In that context, a quote is needed to capture the space. The quote can be either type. But the filename already contains both types. So whichever type is used, the string terminates early.

The robust solution is probably (I'm not sure) to use the tokenizer in token.c instead of the simplistic code that is currently used.

Personally, I use clean filenames.