'Compare' hanging on filenames with asterisks

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Sean Colombo
Posts: 4
Joined: 2012-07-09T08:58:02-07:00
Authentication code: 13

'Compare' hanging on filenames with asterisks

Post by Sean Colombo »

I've run compare on about 6 million files, but I've run into a stumbling-block where it hangs indefinitely on a file which contains a bunch of asterisks in the name.

Here is the exact command I'm using:

Code: Select all

compare -metric MEPP "/raid/compressed_images/by_id/b/bakugan-world/images/9/9c/************************_jpegoptim.jpg" "/raid/images/by_id/b/bakugan-world/images/9/9c/************************.jpg" /dev/null 2>&1
Things I've checked so far:
  • Changing from double-quotes to single-quotes didn't help it
  • The files themselves are both valid (and appear to be identical... almost all of the images in our collection that we compare ARE identical).
  • That I was just being impatient (I let the compare command run for DAYS and it didn't finish... these are fairly small files too... like 400x400 or something).
Any ideas what is wrong or why compare would hang on these files?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: 'Compare' hanging on filenames with asterisks

Post by fmw42 »

To help the IM developers, you should provide your IM version and platform.
Sean Colombo
Posts: 4
Joined: 2012-07-09T08:58:02-07:00
Authentication code: 13

Re: 'Compare' hanging on filenames with asterisks

Post by Sean Colombo »

fmw42 wrote:To help the IM developers, you should provide your IM version and platform.
Good call:
$> compare --version
Version: ImageMagick 6.5.7-8 2010-12-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: OpenMP

$> cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.2 LTS"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: 'Compare' hanging on filenames with asterisks

Post by fmw42 »

see
viewtopic.php?f=3&t=19215&p=75037&hilit ... ers#p75037

Anthony will have to help here if this does not answer your question.

Also you have a very old version of IM. I cannot say if this has been corrected since then, given the reference.
Sean Colombo
Posts: 4
Joined: 2012-07-09T08:58:02-07:00
Authentication code: 13

Re: 'Compare' hanging on filenames with asterisks

Post by Sean Colombo »

fmw42 wrote:see
viewtopic.php?f=3&t=19215&p=75037&hilit ... ers#p75037

Anthony will have to help here if this does not answer your question.

Also you have a very old version of IM. I cannot say if this has been corrected since then, given the reference.
Thanks! That page was just what I needed. Escaping the asterisks didn't work, but replacing them with question marks will work for my use-case.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: 'Compare' hanging on filenames with asterisks

Post by anthony »

IM is trying to handling the '*' as a GLOB filename expandsion expression.
see IM Examples Filename Handling, Meta-characters
http://www.imagemagick.org/Usage/files/#read_meta

When escaping you need to not only escape the shell, but also within the quotes for IM

EG: for the literal filename ***.jpg you will need to use '\*\*\*.jpg' Note both quotes AND backslashes.

For IMv7 I will be looking at some settings to control and disable the internal filename GLOB expansion and other 'read modifiers' (actually for as a security control option).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Sean Colombo
Posts: 4
Joined: 2012-07-09T08:58:02-07:00
Authentication code: 13

Re: 'Compare' hanging on filenames with asterisks

Post by Sean Colombo »

anthony wrote: EG: for the literal filename ***.jpg you will need to use '\*\*\*.jpg' Note both quotes AND backslashes.
I tried with all permutations of both single and double-quotes and single and double backslashes. None of them worked in my case. I don't have the results in front of me, but as I recall it, when I used backslashes the error message was that "the file \*\*\*[etc.]" could not be found. Both single and double backslashes lead to an error-message which indicated it was looking for the single-slashed version.

Hopefully this has something to do with our servers having an old version of IM... but it doesn't sound like this has surfaced terribly often, so it's possible the bug is still lingering. I'm happy to provide the exact image files if you guys wish to debug it. I have a rough workaround for my needs though.
anthony wrote: For IMv7 I will be looking at some settings to control and disable the internal filename GLOB expansion and other 'read modifiers' (actually for as a security control option).
Such a setting seems quite useful :)
Post Reply