OS.execute does not return output in specific cases

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jan Heemstra

Some background: I am writing a compiler for a university course, and wanted to create a very simple editor which can compile upon save, and show errors where they occur. I decided to write the editor in Godot, and I need to call my compiler from the editor with the following command:

stack exec compiler-construction-exe material/tests/test.spl

The following code produces a text entry in the output array, which is equal to the text printed to console when I execute “stack” in a command prompt:

var output = []
var pid = OS.execute('stack', [], true, output)

And so does

	var output = []
var pid = OS.execute('stack', ['--version'], true, output)

But, the following command does not produce any output; the output array remains empty:

var output = []
var pid = OS.execute('stack', ['exec'], true, output)

And neither does:

var output = []
var pid = OS.execute('stack exec', [], true, output)

while executing “stack exec” in a command prompt results in an error printed to console:

Missing: CMD

Usage: stack.exe exec CMD [-- ARGS (e.g. stack exec -- ghc-pkg describe base)]
                      ([--plain] | [--[no-]ghc-package-path] [--[no-]stack-exe]
                      [--package ARG] [--rts-options RTSFLAG] [--cwd DIR])
                      [--help]
  Execute a command

The full command does not work either.

I’m using Windows 10.
How could this discrepancy be caused? How can I fix it, and get the output data I need?

Had a similar problem with git command.

_d = OS.execute('git',[],true,output);

runs fine but

_d = OS.execute('git',['pull'],true,output);

and

_d = OS.execute('git pull',[],true,output);

both don’t work.

I checked the response code _d and it returned 128 when it broke.
Dunno what 128 means though. Nobody ever mentioned it.

Shaqpower3 | 2021-06-03 14:36