Handle empty clipboard for all providers

Closes #6254
This commit is contained in:
Mahmoud Al-Qudsi 2019-10-27 12:31:35 -05:00
parent 56b4763c67
commit ae6bdfa37c

View file

@ -1,21 +1,20 @@
function fish_clipboard_paste
set -l data
if type -q pbpaste
set data (pbpaste)
set data (pbpaste 2>/dev/null)
else if set -q WAYLAND_DISPLAY; and type -q wl-paste
set data (wl-paste)
set data (wl-paste 2>/dev/null)
else if type -q xsel
# Return if `xsel` failed.
# That way we don't print the redundant (and overly verbose for this) commandline error.
# Also require non-empty contents to not clear the buffer.
if not set data (xsel --clipboard 2>/dev/null)
return 1
end
set data (xsel --clipboard 2>/dev/null)
else if type -q xclip
if not set data (xclip -selection clipboard -o 2>/dev/null)
return 1
end
set data (xclip -selection clipboard -o 2>/dev/null)
end
# Issue 6254: Handle zero-length clipboard content
if not string match -qr . -- "$data"
return 1
end
# Also split on \r to turn it into a newline,
# otherwise the output looks really confusing.
set data (string split \r -- $data)