Swi-prolog: remove '|:' before entering the user into the compiled program
Whenever I compile something with swi-prolog it adds |:
before the user input to indicate that you should write something, which would be fine, but I need to pipe the output of this program to another program, preferably without |:
...
My compilation options:
swipl -nodebug -g true -O -q --toplevel=quiet --stand_alone=true -o main -c main.pl
source to share
You need to say
prompt(_, '')
somewhere in your program before you start reading and writing standard streams. From the entry forprompt/2
:
A prompt is displayed if one of the read predicates is called and the cursor is to the left. It also prints whenever a newline is given and this term has not been interrupted. Requests are output only when the current input stream is a user.
The above call just sets up an empty atom prompt (ignoring whatever came before). For example, with the following prompt.pl
:
:- current_prolog_flag(verbose, silent).
:- use_module(library(readutil)).
main :-
read_line_to_codes(user_input, Line),
format("~s~n", [Line]),
halt.
main :- halt(1).
Then:
$ swipl -q --goal=main -o prompt -c prompt.pl
$ ./prompt
|:foobar
foobar
$
: - current_prolog_flag (verbose, silent). : - use_module (library (readutil)). main: - prompt (_, '') , read_line_to_codes (user_input, Line), format ("~ s ~ n", [Line]), halt. main: - halt (1).
And he left:
$ swipl -q --goal=main -o prompt -c prompt.pl $ ./prompt foobar foobar $
If you have included a program similar to my first version prompt.pl
and the result is the same, it would be easier if more people understood what you are asking.