From j.clayden at ucl.ac.uk  Fri Sep 26 22:35:52 2008
From: j.clayden at ucl.ac.uk (Jon Clayden)
Date: Fri, 26 Sep 2008 21:35:52 +0100
Subject: [Rd] R --interactive and readline() creates infinite loop
In-Reply-To: <48DBB07D.5070302@biostat.ku.dk>
References: <98A53690-6407-4E86-A094-27707C77C744@ucl.ac.uk>
	<48DB8E97.9000609@r-project.org> <48DB93F7.8000509@biostat.ku.dk>
	<48DBA1A8.2030602@r-project.org> <48DBB07D.5070302@biostat.ku.dk>
Message-ID: <68e086180809261335p735959eckc1c7dbf8e67460e@mail.gmail.com>

2008/9/25 Peter Dalgaard <p.dalgaard at biostat.ku.dk>:
> John Chambers wrote:
>>
>> My application, at least, wanted to show (my class) individual commands
>> from the file and then optionally insert some typed commands before going on
>> to the next part of the source file. As far as I can see, the piped shell
>> command approach will have to treat the whole file at one time.
>
> Hmmno... You can "cat -" multiple times if you want, terminating each with
> ctrl-D. That's not to say that it is the optimal solution though. Echoing
> the non-keyboard input seems a bit tricky, for instance.

Yes, looking more into it, the fact that everything gets echoed this
way is less than ideal. And for some reason, presumably to do with the
details of the behaviour of "cat", if I do

(echo 'print(readline("Input:"));q()'; cat -) | R --interactive --no-save

I need an extra newline after giving the input before I get returned
to the shell, even though R seems to have quit already. So I don't
think this is the answer. The "demoSource" approach is interesting,
but I think running two R sessions is also going to be problematic for
my application.

It really would be nice if R could do this kind of thing itself. I
would have thought it would make creating some simple "pass-through"
front-ends (like mine ;) ) very easy. I have very little knowledge of
the R source though, so I acknowledge that it may not be an easy task.

Jon



[Rd] R --interactive and readline() creates infinite loop
Jon Clayden