Support copy command on windows and wsl #1153
Open
+9
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enable the
copycommand on Windows and WSL environments.The
copycommand now works both on Windows Ruby and on WSL, copying the evaluated result to the system clipboard.Examples
Windows (mingw-ucrt)
WSL
Windows workaround
On Windows, passing text via stdin does not work reliably in IRB. After calling
IO.popen, IRB’s input handling becomes unstable, but I have not fully identified the root cause yet.To work around this, the Windows implementation invokes PowerShell’s
Set-Clipboardand passes the text via command-line arguments instead of stdin:This approach works reliably on native Windows Ruby.
This issue is likely not limited to the
copycommand, and there may be other cases where IRB does not behave correctly. If this problem can be resolved, it should be possible to simply callclip.exeeven on Windows. I plan to investigate this separately.