[fpc-pascal] ReadLine history works in windows/cmd.exe but not in bash/linux

Michael Van Canneyt michael at freepascal.org
Wed Sep 1 21:13:22 CEST 2010



On Wed, 1 Sep 2010, Dusan Halicky wrote:

>>> I compiled it in windows (FPC 2.4.0), run it in cmd.exe and I was
>>> surprised that history of commands is working out of the box (by
>>> pressing arrow UP).
>>
>> That is standard behaviour for most modern shells.
>> The readln() function has nothing to do with libreadline.
>>
>> The problem you are seeing is due to the shell you are using and the
>> key binding options you have assigned or defaulted to in the shell
>> and/or the terminal emulator. It has nothing to do with FPC.
>
> So you are saying, that cmd.exe is monitoring what am I typing, and
> when test.exe is waiting on `readln(s)` and I press UP, then cmd.exe
> somehow paste to STDIN what I typed 1 EOL before?

Yes, that is correct.

If you run the program twice, you'll see that you can "scroll back" even 
to what you typed in the first run of the program; This is clear proof 
that it is not the program itself which does that.

Michael.



More information about the fpc-pascal mailing list