[R] bugs in system() handling long character strings??
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Sat Dec 7 23:51:02 CET 2002
There is an undocumented limit of 119 characters/line when using
system(intern=TRUE) on Unix. You can easily raise it: it is in
do_system in file src/unix/sys-unix.c.
I think this limit should be raised considerably, but it may well not be
worth eliminating it.
On Sat, 7 Dec 2002, Naoki Takebayashi wrote:
> Hi,
>
> system(cmd, intern=T) seems to have a problem when cmd returns a long
> character string.
>
> For example, if a file (/tmp/long.txt) contains a long string such as:
>
> 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
>
> There are 120 characters in this one line.
>
> > junk <- system("cat /tmp/long", TRUE)
> > junk
> [1] "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"
> [2] "0"
> > nchar(junk[1])
> [1] 118
>
> So one long line get separated into two parts, and additionally 119-th
> character is missing.
>
> Is this a bug in R or am I missing something?
>
> I tried this on R-1.6.1 on linux/alpha and linux/i386.
>
> Thanks,
> Naoki
>
> Naoki Takebayashi <ntakebay at bio.indiana.edu>
> --- Dept. of Biology, Box 90338, Duke University, Durham, NC 27708-0338
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list