opened 08:25PM - 05 Nov 20 UTC
closed 10:14AM - 09 Nov 20 UTC
Problematic command
-------------------
``` sh
echo "text to copy" | wl-cop…y | cat
```
Expected behavior
-----------------
Nothing gets sent through stdout; the useless `cat` should receive no input.
Actual behavior
---------------
`cat` is never called; wl-copy hangs.
Real-life example
-----------------
I wanted to write some scripts that involved copying `stdin` to the clipboard and sending it to other programs. To simplify this collection of scripts, I planned on making a small script called `wlcv` that just wrapped `wl-copy` to make it noisy; it would copy `stdin` and send it to `stdout`. I wanted to accomplish this with the [`pee`](https://manpages.ubuntu.com/manpages/hirsute/man1/pee.1.html) command, but I ran into this issue:
``` sh
$ # Exhibit A (works):
$ echo "https://funny-link.com" | pee cat 'wl-copy -n'
$ # Exhibit B (doesn't work):
$ echo "https://funny-link.com" | pee cat 'wl-copy -n' | text-friends
$ # Exhibit C (works):
$ echo "https://funny-link.com" | pee 'wl-copy -n' 'text-friends'
```
Exhibit A is the gist of `wlcv`, and seems to work.
Exhibits B and C should behave identically; `https://url-to-share.com` should be sent to `text-friends` (a script that texts stdin to my friends). The `wl-copy -n` command in Exhibit B hangs; my friends never get texted. Exhibit C works as intended.
As a result of this bug, I can’t use `wlcv` the way I wanted because `wlcv` hangs when followed by a pipe:
``` sh
# text friends a funny link and copy it so I can paste it into some IRC channels for sharing
$ wlcv "https://funny-link.com" | text-friends
# upload a file to a file-sharing website, copy the URL for sharing, and open it in my browser to preview.
curl -F"file-@path/to/file" https://0x0.st | wlcv | $BROWSER
```