Release of G'MIC 2.8

New in 2.8.1 :

As you may know, G’MIC defines its own script language and embeds the corresponding interpreter. In upcoming version 2.8.1, a special running mode will be added in G’MIC, allowing gmic to implicitly generate an entry point in a .gmic file, so that including such a file with command input automatically runs the code defined in the entry point.

This mode is activated only when gmic is called with a single argument, which is the .gmic file to consider, i.e.

$ gmic test.gmic

In this case, if test.gmic contains some code defined outside the body of some user-defined commands, then it will be considered as a part of a new implicit command _main_, and executed after loading the file.

Moreover, on Unix systems, you can use a Shebang line in test.gmic and make it directly executable (just as you can do it with python or php). For instance, define your file test.gmic like this:

#!/usr/bin/gmic
# This file can be made executable.

echo "Starting entry point"
if date(3)==1
  echo[] "\nIt's monday !\n"
else
  echo[] "\nToday is not monday !\n"
fi
echo "Exiting entry point\n"

And then, on Unix :

$ chmod a+x test.gmic
$ ./test.gmic
[gmic]-0./_main_/ Starting entry point

Today is not monday !

[gmic]-0./_main_/ Exiting entry point

On other systems (that do not support Shebang), you can get the same behavior with

$ gmic test.gmic

You can see in the first and last echo output on the command line that you are indeed running code in a newly created command named _main_.

If you want to debug such a script file, you have to explicitly call _main_', because if you activate the debug` flag on the command line, you are not in the situation of the special running mode, so:

$ gmic test.gmic _main_ debug

In you are interested, you will find some example of such executable files here :

1 Like