From 08cee23ec10f22da1eb54944c8e01564c16a5c33 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Mon, 10 Jul 2017 21:30:00 -0400 Subject: Attempt at fixing some extraneous output on Linux when using Python3 and xclip --- cmd2.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmd2.py') diff --git a/cmd2.py b/cmd2.py index 4fee16af..e638d401 100755 --- a/cmd2.py +++ b/cmd2.py @@ -300,7 +300,12 @@ def options(option_list, arg_desc="arg"): # Can we access the clipboard? Should always be true on Windows and Mac, but only sometimes on Linux try: - _ = pyperclip.paste() + if six.PY3 and sys.platform.startswith('linux'): + # Avoid extraneous output to stderr from xclip when clipboard is empty at cost of overwriting clipboard contents + pyperclip.copy('') + else: + # Try getting the contents of the clipboard + _ = pyperclip.paste() except pyperclip.exceptions.PyperclipException: can_clip = False else: -- cgit v1.2.1