I don’t see inconsistency here. After all, b
could be a valid argument for my_command
. Arguments of commands are not typed, so the G’MIC interpreter knows only there are arguments or not.
If arguments are expected, then forcing the user to put at least a comma seems to be logical.
Anyway, in my_command
, you could additionally check if the provided argument seems to be correct, and if not, use the noarg
command to tell no arguments have been provided.
Like this:
my_command : skip ${1=10}
smoothness=$1
if {!isval($1)} noarg smoothness=10 fi
blur $smoothness
and in that case, a call like $ gmic sample lena my_command mirror x
will apply my_command
with default smoothness
value set to 10
.
This is not the ultimate solution to manage default parameters though, as the interpreter will try to subtitute a given argument of my_command
anyway, with possible side effects giving unexpected results, as in:
foo :
sp lena
my_command x=${"-echo foo u booh"}
that will display foo
twice, as the item following my_command
will be evaluated twice.