diff --git a/share/functions/fish_clipboard_paste.fish b/share/functions/fish_clipboard_paste.fish index 0ed27abce..08c0402b5 100644 --- a/share/functions/fish_clipboard_paste.fish +++ b/share/functions/fish_clipboard_paste.fish @@ -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)