Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions eye.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Loading