clipboard: Reduce unnecessary special-casing on stdin
Ideally the parameter would just be removed-users could always
just do "clipcopy < some-file". but removing the parameter would break
backwards compatibility.
In any case, this simplifies the logic considerably.
Diff
1diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh
2index 2c93d1bb5c3a2af2cca739b96e46c6dbb38d6dd3..15ad6d91683d90d040fab53cb5eb851c79e24b69 100644
3--- a/lib/clipboard.zsh
4+++ b/lib/clipboard.zsh
5@@ -17,32 +17,17 @@
6 #
7 function clipcopy() {
8 emulate -L zsh
9- local file=$1
10+ local file="${1:-/dev/stdin}"
11+
12 if [[ $OSTYPE == darwin* ]]; then
13- if [[ -z $file ]]; then
14- pbcopy
15- else
16- cat $file | pbcopy
17- fi
18+ pbcopy < "${file}"
19 elif [[ $OSTYPE == cygwin* ]]; then
20- if [[ -z $file ]]; then
21- cat > /dev/clipboard
22- else
23- cat $file > /dev/clipboard
24- fi
25+ cat "${file}" > /dev/clipboard
26 else
27 if (( $+commands[xclip] )); then
28- if [[ -z $file ]]; then
29- xclip -in -selection clipboard
30- else
31- xclip -in -selection clipboard $file
32- fi
33+ xclip -in -selection clipboard < "${file}"
34 elif (( $+commands[xsel] )); then
35- if [[ -z $file ]]; then
36- xsel --clipboard --input
37- else
38- cat "$file" | xsel --clipboard --input
39- fi
40+ xsel --clipboard --input < "${file}"
41 else
42 print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
43 return 1