You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sh: echo "hello": command not found
! Command failed.
Failed with status 32512
Working example
Use the same Minafile as above, but first set term_mode to :pretty:
set:term_mode,:pretty
Run mina hello, output:
hello
Elapsed time: 0.01 seconds
So when either Kernel.exec or Kernel.system are called, the command string should not be shell escaped. It should be shell escaped when passed to Mina::ExecHelpers#pretty_system, which does Shellwords.shellsplit on it.
Proposed solution
Since Mina::LocalHelpers::Local.invoke is the responsible for switching between which shell execution method to use, it should be that method to decide whether to shell escape the command or not.
So change it to shell escape only when calling pretty_system and not escaping when calling Kernel methods and change all callers to send the command string as-is.
As far as I can see, the only caller is Mina::LocalHelpers#local.
Sidenote
Why the use of Kernel.exec? According to the docs, it replaces the current process by running the given external command. Is that expected behavior?
The text was updated successfully, but these errors were encountered:
The local_helper.rb is a copy of a ssh_helper.rb file. I will have to extract that into a single method.
For your last question, unfortunately that was written by former owner of mina and i have no knowledge why he used Kernel.exec
I know that we have non pretty_print mode for windows users because open4 is not supported there.
Do you believe it is not necessary at all? I am not fully aware of the cons/pros of the various methods you can call system code, so I would very grateful for some input here.
Mina::LocalHelpers::Local.invoke
receives aShellwords.escape
'd command string that breaksKernel.exec
orKernel.system
.Breaking example
Minafile
containing:Note: the default
:term_mode
setting isnil
.mina hello
, outputs (or errs):Working example
Minafile
as above, but first setterm_mode
to:pretty
:mina hello
, output:So when either
Kernel.exec
orKernel.system
are called, the command string should not be shell escaped. It should be shell escaped when passed toMina::ExecHelpers#pretty_system
, which doesShellwords.shellsplit
on it.Proposed solution
Since
Mina::LocalHelpers::Local.invoke
is the responsible for switching between which shell execution method to use, it should be that method to decide whether to shell escape the command or not.So change it to shell escape only when calling
pretty_system
and not escaping when callingKernel
methods and change all callers to send the command string as-is.As far as I can see, the only caller is
Mina::LocalHelpers#local
.Sidenote
Why the use of
Kernel.exec
? According to the docs, it replaces the current process by running the given external command. Is that expected behavior?The text was updated successfully, but these errors were encountered: