You need to say
prompt(_, '')
somewhere in your program before you start reading and writing to standard streams. From the entry for prompt/2
:
A prompt is printed if one of the read predicates is called and the cursor is at the left margin. It is also printed whenever a newline is given and the term has not been terminated. Prompts are only printed when the current input stream is user.
The invocation above just sets the prompt to the empty atom (ignoring whatever the prompt was 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 it is gone:
$ swipl -q --goal=main -o prompt -c prompt.pl
$ ./prompt
foobar
foobar
$
If you have included a program similar to my first version of prompt.pl
and the resulting output it might have been easier for more people to understand what exactly you are asking.
|:
is printed? try piping it to cat (|cat
)to see if that isn't the case. – Patrick J. S.|:
disappear when piping it to cat. Can you explain why this happens though? – tolUene