check: Technical Reference Documentation Seems in Need of Update

gosgood@bertha ~ $ gmic help check

  check (+):
      condition

    Evaluate specified condition and display an error message if evaluated to false.
    If 'expression' is not a math expression, it is regarded as a filename and checked if it exists.

That last statement seems suspect to me. (“If ‘expression’ is not a math expression…”). I don’t think that has been true since 2.6 ( What’s new in 2.6? ) when if, elif, for, while, ceased accepting direct references to file system objects. Seems check should have been included in that change log as well. In gmic.cpp all five commands avail themselves of gmic::check_cond() and, so near as I can tell, that method embodies no direct file system checking. If I wish to check the existence of a file system object, I should use isfile() or isdir(), with check, consistent with if, elif, for, and while. CLI behavior seems to bear this out:

  1. In fact, ${HOME}/.gmic exists, but the path to this file would also constitute a malformed G’MIC math expression:
gosgood@bertha ~ $ gmic -check "'${HOME}/.gmic'" -echo "Have default linux command module."
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ *** Error *** Command 'check': Expression ''/home/gosgood/.gmic'' evaluated to false.
  1. Use isfile() math expression with check, as with if, elif, for, while . This math expression resolves to True and check doesn’t throw an exception, as one would expect.
gosgood@bertha ~ $ gmic -check "{isfile('${HOME}/.gmic')}" -echo "Have default linux command module."
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Have default linux command module.
[gmic]-0./ End G'MIC interpreter.

${HOME}/idontexist.missing doesn’t exist. The math expression isfile() resolves to False and check throws an exception, as one would expect.

gosgood@bertha ~ $ gmic -check "{isfile('${HOME}/idontexist.missing')}" -echo "Have the missing file."
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ *** Error *** Command 'check': Expression '0' evaluated to false.

The conclusion I draw here that check always takes a math expression, and never regards its argument, alternatively, as a filename or directory.

Seems a case of documentary tally lag, no?

gosgood@bertha ~ $ gmic

  gmic: GREYC's Magic for Image Computing: command-line interface
        Version 3.0.0 (pre-release #211023)
        (https://gmic.eu)

        Copyright (c) Since 2008, David Tschumperlé / GREYC / CNRS.
        (https://www.greyc.fr)
1 Like

Indeed. I’ll fix this. Thanks !