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.
I was investigating the need to use
echo -e
to processbackslash-escaped characters on Linux and was having a ton of trouble
getting the `` command to put the emoji character through the pipe in a
way that it be interpreted correctly. I also ran into the "hanging"
issue described in bintest/emoji-cli.rb#14 which I tried to strace
When using xclip it looks like parent-readable end of the pipe (file descriptor 3) is not being closed which could mean that xclip is potentially still waiting for more data from the parent-writeable end of the pipe (file descriptor 4) which is weird because that was closed above.
I think this must have something to do with how backticks function in mruby: so near as I can tell the shell commands are processed with
sh -c BACKTICK_CONTENTS
but that should still result in a successfully piped emoji character unless sh, echo, or xclip isn't properly reading it as unicode data.I still don't know exactly why the echo command wasn't working on Linux and I'm a bit too unfamiliar with mruby to really dig into it as I am able to run
sh -c "echo -ne 🐧 | xclip -i"
and have it copy the penguin emoji to my selection.Since the mruby-io mrbgem was already present, I rewrote the copy method to use IO.popen rather than backticks to directly write the emoji character to the standard input of the copy command's process.
I haven't yet been able to test this for Mac OS but we can always make it a Linux specific change if it doesn't work or the the backtick of echo is preferred.
cc @muan for review and Mac OS testing.
We might also be able to revisit the tests now that the hang has been resolved.