BlueBrain / nmodl

Code Generation Framework For NEURON MODeling Language
https://bluebrain.github.io/nmodl/
Apache License 2.0
53 stars 15 forks source link

NMODL subcommand order incompatible with `find ... -exec [EXECUTABLE] {} +` #1482

Open JCGoran opened 4 days ago

JCGoran commented 4 days ago

When using find, one often uses the syntax:

find ... -exec [EXECUTABLE] {} \;

as a shorthand for running [EXECUTABLE] [MATCH1];[EXECUTABLE] [MATCH2]; ... (single input file to [EXECUTABLE]), and:

find ... -exec [EXECUTABLE] {} +

as a shorthand for [EXECUTABLE] [MATCH1] [MATCH2] ... (multiple input files to [EXECUTABLE]). The problem is that the latter does not work with NMODL subcommands:

$ find . -name '*.mod' -exec nmodl {} passes --nmodl-ast +
find: -exec: no terminating ";" or "+"
$ find . -name '*.mod' -exec nmodl passes --nmodl-ast {} +
file: File does not exist: passes
Run with --help or --help-all for more information.
$ find . -name '*.mod' -exec nmodl {} + passes --nmodl-ast
find: passes: unknown primary or operator

My guess is that there's an assumption in find that the input files are always the last part of the command, which isn't the case for NMODL. This can be a bit limiting since the two forms (with {} \; and with {} +) are not equivalent if there are any changes to the traversed dir done as a result of running [EXECUTABLE]. This is the case by default for NMODL (writes temp files in ${PWD}/tmp), but which can be circumvented by explicitly specifying --scratch-dir [DIR]. Would be nice not to have to use this workaround though.