IM 7 command-line tools don't understand the -- option

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
deflate
Posts: 2
Joined: 2018-03-31T04:16:02-07:00
Authentication code: 1152

IM 7 command-line tools don't understand the -- option

Post by deflate » 2018-03-31T04:21:07-07:00

Code: Select all

$ identify -ping -- image.jpg
identify: unrecognized option `--' @ error/identify.c/IdentifyImageCommand/920.
IM 6.x did.

Code: Select all

$ identify --version
Version: ImageMagick 7.0.7-19 Q16 x86_64 2018-03-17 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): cairo djvu freetype jng jpeg lcms ltdl pangocairo png rsvg tiff x xml zlib

snibgo
Posts: 10717
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: IM 7 command-line tools don't understand the -- option

Post by snibgo » 2018-03-31T04:25:11-07:00

IM v7 has a different, more strict command interpreter than v6.

Is "--" a documented feature?
snibgo's IM pages: im.snibgo.com

deflate
Posts: 2
Joined: 2018-03-31T04:16:02-07:00
Authentication code: 1152

Re: IM 7 command-line tools don't understand the -- option

Post by deflate » 2018-03-31T04:28:53-07:00

"--" is the standard unix way of telling a program that there will be no "-X" or "--XXX" (replace X and XXX with any letter/word) options after it. Sometimes filenames start with a hyphen, so "--" is essential to prevent confusion.

snibgo
Posts: 10717
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: IM 7 command-line tools don't understand the -- option

Post by snibgo » 2018-03-31T05:31:00-07:00

Yes. The common unix convention for program arguments is to list options and then filenames, and "--" prevents programs from thinking that filenames that start with "-" are options. This is great for "filter" programs that have exactly one input and one output.

But ImageMagick can take any number of input and output filenames (eg 10,000), with options that apply to some filenames, and options that apply to intermediate results, and so on. So IM adopted a convention more like a programming language, where all operations (including reading and writing files) are given in the order they should be performed.

With that convention, leaving the filenames to the end makes no sense.

IM v6 didn't enforce that convention, and still accepted the unix format of leaving filenames to the end.

IM v7 does enforce the sequencing order, so "--" is redundant.

Sadly (in my view), IM distinguishes between filenames and options by "-", so filenames usually cannot start with "-". However, IM v7 has explicit read and write operations, so we can do this:

Code: Select all

magick -read rose: -write -x.png -exit

magick -read -x.png x2.png
snibgo's IM pages: im.snibgo.com

Post Reply