From 0438c63fa8d379500d3a724c4b349dc65e290c6f Mon Sep 17 00:00:00 2001 From: Jesse Wright <63333554+jeswr@users.noreply.github.com> Date: Sat, 4 Jul 2026 21:48:22 +0000 Subject: [PATCH] Pass exec/2 commands to the javascript host in the wasm version In the wasm version there is no shell/2, so the graph scoped builtins (log:collectAllIn, log:forAllIn, log:ifThenElseIn, log:conclusion, log:satisfiable, e:call, e:fail and e:findall) could not spawn their eye sub-reasoner. Following the userInput/2 precedent, exec/2 now yields exec(Args, File) to the javascript host via await/2 under the emscripten condition, where Args is the argv of the command and File is the target of its stdout redirection. See https://github.com/eyereasoner/eye-js/issues/873 Co-Authored-By: Claude Fable 5 --- eye.pl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/eye.pl b/eye.pl index a7fc75c62..f07a55085 100644 --- a/eye.pl +++ b/eye.pl @@ -12933,12 +12933,37 @@ ), tmp_file(C, A). +:- if(current_prolog_flag(emscripten, true)). +% there is no shell in the wasm version so the command is passed to the +% javascript host as exec(Args, File) via await/2, where Args is the argv +% of the command and File is the target of its stdout redirection. The +% host is expected to run the command, e.g. the eye sub-reasoner spawned +% by the graph scoped builtins on a fresh wasm module, write the standard +% output to File and answer "ok" +exec(A, B) :- + atomic_list_concat(C, ' ', A), + findall(D, + ( member(D, C), + D \== '' + ), + E + ), + ( append(F, ['>', G|_], E) + -> await(exec(F, G), H), + ( H == "ok" + -> B = 0 + ; throw(exec_error(A)) + ) + ; throw(exec_error(A)) + ). +:- else. exec(A, B) :- shell(A, B), ( B =:= 0 -> true ; throw(exec_error(A)) ). +:- endif. getcwd(A) :- working_directory(A, A).