Skip to content

clipboard(x) blocks indefinitely (maybe just on Linux?) #14510

@ghost

Description

julia> clipboard("Help, I'm trapped inside the computer!")
Waiting for selection requests, Control-C to quit
  Waiting for selection request number 1

Here Julia is waiting on xclip, which runs until another program intercedes to reset the clipboard. It would be more convenient -- for me, at least -- if xclip and xsel could detach themselves and run in the background. That way, we could carry on with our program in the meantime. It would only take an option change to fix:

--- base/interactiveutil.jl
+++ base/interactiveutil.jl
@@ -108,8 +108,8 @@
     end
     function clipboard(x)
         c = clipboardcmd()
-        cmd = c == :xsel  ? `xsel --nodetach --input --clipboard` :
-              c == :xclip ? `xclip -quiet -in -selection clipboard` :
+        cmd = c == :xsel  ? `xsel --input --clipboard` :
+              c == :xclip ? `xclip -silent -in -selection clipboard` :
             error("unexpected clipboard command: $c")
         open(pipeline(cmd, stderr=STDERR), "w") do io
             print(io, x)

(Compare–contrast the clipboard() method, where running in the foreground is natural; xsel and xclip return as soon as they've retrieved its contents.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    REPLJulia's REPL (Read Eval Print Loop)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions