Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- execute(Command, Args, Trace, Trace):-
- process_create(Command, Args, [stdout(pipe(In))]),
- report_command_output(Trace, In),
- close(In).
- report_command_output(Trace, In):-
- peek_char(In, Char),
- (Char = end_of_file ->
- true
- ;
- read_line(In, Line),
- trace_message(Trace, '~w', [Line]),
- report_command_output(Trace, In)
- ).
- read_line(In, Line):-
- read_line(In, [], Line).
- read_line(In, Cs, Line):-
- get_char(In, Char),
- (Char = '\n' ->
- reverse(Cs, Cs1),
- atom_chars(Line, Cs1)
- ;
- read_line(In, [Char|Cs], Line)
- ).
Add Comment
Please, Sign In to add comment