From simon.urbanek at r-project.org  Thu Nov  7 01:41:57 2013
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Wed, 6 Nov 2013 19:41:57 -0500
Subject: [Rd] cat with backspace and newline characters
In-Reply-To: <CAHavPHHwsSq05zhDcCVMBo6kbvgBRwetCx45H19knmRU1xs-_Q@mail.gmail.com>
References: <CAHavPHGe1A7R6RxD45exQnq7zJXWatiKQ8rR7SiFJBE2RGVQDQ@mail.gmail.com>
	<CADv2QyG6Nvn+YJ46Pz5PF7FqB9Q-LnEeLE4_EAgfVgBKo+EakA@mail.gmail.com>
	<CAHavPHH7VMYxBLjJsDO_2wwS-tC=gwbHiMfXVeP4fhXPZiJwNg@mail.gmail.com>
	<CAH7sKSN6a7ObU8g7xXf+fHq0cdMeKvsr7PSsorhNZ=DP3Pf8Ow@mail.gmail.com>
	<21112.61708.698124.149056@stat.math.ethz.ch>
	<8E2469B4-2A7B-44DD-896F-F409C39F4496@sciviews.org>
	<21113.8847.603856.486049@stat.math.ethz.ch>
	<A750360B-31A8-49EB-B21F-87EE4BA6E412@gmail.com>
	<CANROs4e=Do0ejPc7w=rOzG8zzNdhkmYWFJN=qU61JQRGnLWiPQ@mail.gmail.com>
	<CAHavPHHwsSq05zhDcCVMBo6kbvgBRwetCx45H19knmRU1xs-_Q@mail.gmail.com>
Message-ID: <15FAF9D3-1BA6-48EA-8B98-1347B97256CD@r-project.org>


On Nov 6, 2013, at 3:47 AM, Renaud Gaujoux <renaud at mancala.cbio.uct.ac.za> wrote:

>> Anyway,
>> thanks for all the experiments, and (to Renaud) support.rstudio.org is
>> the place to report such problems.
>> 
> 
> Funny how the post diverged to an RStudio-related issue.
> Anyway, I posted a link to this post at support.rstudio.org:
> http://support.rstudio.org/help/discussions/problems/9242-cat-with-backspace-and-newline-characters/
> 
>> From the user point of view, the following behaviour still feels like a
> strange behaviour of the R prompt:
> 
>> cat("abc\b\b\b")
>> c
> (with the cursor now position on the 'c?)

That is not strange at all - just try adding something like Sys.sleep(2) to understand it - it?s exactly what you should expect in a typical terminal (but see below) and it?s happens with any program (try perl -e 'print STDERR "abc\b\b\b"; sleep 1;? for example).


> I don't know if there is a general official behaviour of prompt characters,
> but I think one expects the prompt to always follow whatever is printed by
> the previous R command, without corruption of the input line to be.
> 

I don?t think that there is any guaranteed behavior for anything other than ?\n?. All cat() guarantees is that this character sequence will be passed out to the console, there is no guarantee as to what effect it will actually have - that is entirely up to the front-end.

Thus your implicit assumption is that ?\b? is interpreted in some way, but it?s not - it?s simply passed on. When running on a terminal, it is interpreted by the terminal, and the standard interpretation is to move the cursor to the left by one character. If running R through any other means like a GUI, it?s entirely up to the GUI to decide whether to interpret non-ASCI characters in some way - or not.

Cheers,
Simon



> Renaud
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 



[Rd] cat with backspace and newline characters
Simon Urbanek