Command akin to eval.

There’s a separate behavior of eval when a image is selected to be processed on. Can this be done with custom command?

Like a way for G’MIC to tell if there is [ind] or periods when the command is called? No, not looking for is_image_arg. That is about [ind] as an argument. I mean this command[ind] as opposed to command [ind].

Not sure about eval or changing command behaviour. I vaguely recall that the latter is possible within scripting.

As for command indexing, I suppose you can compare the number of images available vs what is being referenced. If there is a difference, then indexing is used. If not, then the argument form. The only exception to this method would be when the count is equal for both, then the command would not know if an argument is also an index, unless you have an extra parameter in the command when expecting an index parameter. And what if the user decided to do command[ind] [ind]? You would have to consider that as well.

I don’t think this is likely. And I think there would be a new substitition rule if this were to be implemented. $+ or $@ are both my candidate. So, they can be two different [ind].

The reason I am asking for this feature request is that I would like a command to be used as a pipeline or for processing individual image. My string related commands would benefit from something like this.

P.S, I know you can do pass command, but I don’t need to pass images.

In a command, you can use $[] to get the list of indices of selected images (from the parent context). So, you can still to this trick:

foo :
  if [$[]]==[${"pass -1"}]
    e "NO SELECTION (or FULL SELECTION)"
  else
    e "SELECTION : $[]"
  fi

The problem is that there is no simple way then to distinct between “no selection” and “full selection”. So, foo[^] and foo will both lead to the first case of the if clause.

1 Like