On 2/18/24 00:23, Jennifer Bryan wrote:
I've now tested with:
> R.version.string
[1] "R Under development (unstable) (2024-02-16 r85931)"
and all of the previously mentioned examples now work as expected on
macOS.
Thanks for the quick fix,
Thanks for the testing,
Tomas
Jenny
On Thu, Feb 15, 2024 at 8:02 AM Tomas Kalibera
<tomas.kalib...@gmail.com> wrote:
On 2/14/24 23:43, Jennifer Bryan wrote:
> Hello,
>
> I've noticed a specific type of pipe() usage that works in
released R, but
> not in r-devel.
>
> In 4.3.2 on macOS, I can write to a connection returned by
pipe(), i.e.
> "hello, world" prints here:
>
>> R.version.string
> [1] "R version 4.3.2 (2023-10-31)"
>> con <- pipe("cat")
>> writeLines("hello, world", con)
> hello, world
>
> But in r-devel on macOS, this is silent no-op, i.e. "hello,
world" does not
> print:
>
>> R.version.string
> [1] "R Under development (unstable) (2024-02-13 r85895)"
>> con <- pipe("cat")
>> writeLines("hello, world", con)
> My colleague Lionel Henry confirms he sees the same results on
linux.
> This particular example with cat doesn't work on Windows, so I
don't have
> any useful observations for that OS.
>
> You might say this is a weird example or use case. The actual
usage where I
> discovered this is the way folks read/write the clipboard on
macOS using
> pbcopy/pbpaste (and, in very similar ways, on linux using xsel
or xclip).
> This is mentioned in the "Clipboard" section of the connections
help topic.
>
> In 4.3.2 on macOS, I can successfully roundtrip with the clipboard:
>
>> pb_write <- pipe("pbcopy")
>> writeChar("hello clipboard!", pb_write, eos = NULL)
>> pb_read <- pipe("pbpaste")
>> readChar(pb_read, 16)
> [1] "hello clipboard!"
>
> In r-devel, it appears that the write operation silently does
nothing:
>
>> pb_write <- pipe("pbcopy")
>> writeChar("hello clipboard!", pb_write, eos = NULL)
>> pb_read <- pipe("pbpaste")
>> readChar(pb_read, 16)
> character(0)
>
> If the clipboard is populated through other means, I can
> use readChar(pipe("pbpaste"), ...) to read the clipboard even in
r-devel.
> So this seems to be specific to writing to the connection.
>
> Is this change in behaviour intentional and will it be present
in the next
> release of R? FWIW, I did a crude search of the source of all
CRAN packages
> and there are quite a few currently using pipe() for clipboard
access on
> *nix.
This should be fixed now in R-devel. Thanks for the report and
thanks to
Ivan for the debugging. It would be great if you could test on
your end
with different examples and report any other issues.
Thanks
Tomas
>
> -- Jenny
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel