Query interpreter version to select its arguments/options and even some specific configuration #172
Labels
enhancement
something nice to have but it is not neither critical nor urgent
Milestone
Describe the feature you'd like
byexample
should query the interpreter and get its version. The idea is that an interpreter may deprecate some flags or add new ones in future releases.byexample
has a single set of flags and configuration per interpreter. Detecting which version is, it will allow to have a flags/options/configuration per version.A concrete case is
irb 1.2.1
(ruby
). In older versions,irb
works fine with the--readline
flag but since1.2.1
it breaks (#162 ).The issue can be fixed adding two more options
--nomultiline
and--nocolorize
. But these are incompatible with older version ofirb
.This is a concrete example where we need to have a specific config per interpreter version.
Additional context (optional)
Performance
Querying means that
byexample
will have to spawn an interpreter. It has a non-trivial runtime cost so we should cache it once perbyexample
run.We could use
subprocess.check_output
instead ofpexpect
because we don't need any fancy with terminals.check_output shell
parameter must beFalse
to ensure that the command will not be interpreted by any shell like in the case ofpexpect
.Compatibility
Spawning an interpreter it means that we have to honor the
shebang
configuration. Currently this is%e %p %a
.We could replace the interpreter's default value for
%a
by--version
or something similar. There could be a problem if the user changes theshebang
and it does not use%a
so no--version
flag will be put and the run will fail.We could force the
--version
flag after theshebang
but it will break in other cases (probably).Even if
%a
is used, the user may had changed the interpreter binary (%p
) and now the--version
is not the correct flag for that binary or if it is, it may not output the same as the original binary and the parsing of the version string could fail.Given all of this I'm inclined to go for the "replace
%a
" strategy and make the "query interpreter version" a "best effort".The text was updated successfully, but these errors were encountered: