From maechler at stat.math.ethz.ch  Tue Nov  5 14:22:20 2013
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 5 Nov 2013 14:22:20 +0100
Subject: [Rd] cat with backspace and newline characters
In-Reply-To: <CAH7sKSN6a7ObU8g7xXf+fHq0cdMeKvsr7PSsorhNZ=DP3Pf8Ow@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>
Message-ID: <21112.61708.698124.149056@stat.math.ethz.ch>

>>>>> Kenn Konstabel <lebatsnok at gmail.com>
>>>>>     on Tue, 5 Nov 2013 13:25:20 +0200 writes:

    > I just tried it on ubuntu but within RStudio:
    >> cat("abc\b")
    > ab
    >> cat("abc\b\n")
    > ab
    >> sessionInfo()

which --- as you allude to below --- shows that  RStudio  has changed R
in so far that it adds a '\n'  even when R, i.e.  cat()  does not.

I can understand that the RStudio programmers want to protect
their users (*) from getting funny looking output,
but I still don't like the fact that R inside RStudio is tweaked
to behave differently from regular R. 

Martin Maechler, R Core Team & ETH Zurich

--
(*) or their software from malfunctioning when the console "looks ugly"

    > R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu
    > (64-bit)

    > locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C
    > LC_COLLATE=C [5] LC_MONETARY=C LC_MESSAGES=C LC_PAPER=C
    > LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C
    > LC_IDENTIFICATION=C

    > --------

    > On the same machine but running R in the terminal (tried
    > with GNOME terminal, Konsole, and xterm with no difference
    > )

    >> cat("abc\b")
    ab> cat("abc\b\n")
    > abc
    >> sessionInfo()
    > R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu
    > (64-bit)

    > locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C
    > [4] LC_COLLATE=C LC_MONETARY=C LC_MESSAGES=C [7]
    > LC_PAPER=C LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C
    > LC_MEASUREMENT=C LC_IDENTIFICATION=C

    > ---------


    > But then again ...

    > cat("abc\b \n")

    > ... seems to work the same way everywhere. It looks like
    > the logic in a unix terminal is that \b moves the cursor
    > backwards but does not replace or delete anything that was
    > there before.

    > Regards, Kenn





    > On Tue, Nov 5, 2013 at 12:53 PM, Renaud Gaujoux <
    > renaud at mancala.cbio.uct.ac.za> wrote:

    >> Maybe it's a Linux problem:
    >> 
    >> > cat("abc\b")
    ab> cat("abc\b\n")
    >> abc > sessionInfo() R version 3.0.2 (2013-09-25)
    >> Platform: x86_64-pc-linux-gnu (64-bit)
    >> 
    >> locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3]
    >> LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5]
    >> LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7]
    >> LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C
    >> LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8
    >> LC_IDENTIFICATION=C
    >> 
    >> attached base packages: [1] stats graphics grDevices
    >> utils datasets methods base
    >> >
    >> > Sys.info() sysname "Linux" release "3.11.0-12-generic"
    >> version "#19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013"
    >> nodename "XXXXX" machine "x86_64" login "XXXXX" user
    >> "XXXXX" effective_user "XXXXX"
    >> >
    >> 
    >> 
    >> 
    >> 
    >> On 1 November 2013 19:54, Dennis Murphy
    >> <djmuser at gmail.com> wrote:
    >> 
    >> > I can't reproduce the error, either:
    >> >
    >> > > cat("abc\b") > ab> cat("abc\b\n") > ab
    >> > >
    >> > > sessionInfo() > R version 3.0.2 (2013-09-25) >
    >> Platform: x86_64-w64-mingw32/x64 (64-bit)
    >> >
    >> > locale: > [1] LC_COLLATE=English_United States.1252 >
    >> [2] LC_CTYPE=English_United States.1252 > [3]
    >> LC_MONETARY=English_United States.1252 > [4] LC_NUMERIC=C
    >> > [5] LC_TIME=English_United States.1252
    >> >
    >> > <package info snipped for brevity>
    >> >
    >> > Dennis
    >> >
    >> 
    >> [[alternative HTML version deleted]]
    >> 
    >> ______________________________________________
    >> R-devel at r-project.org mailing list
    >> https://stat.ethz.ch/mailman/listinfo/r-devel
    >> 

    > 	[[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
Martin Maechler