summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-07-10 21:30:00 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-07-10 21:30:00 -0400
commit08cee23ec10f22da1eb54944c8e01564c16a5c33 (patch)
tree6c1c02c6fefb7f82616cd87711b0a44ca285ab32 /cmd2.py
parentb9c56fd456b84f7eaeb98f393603907f4bf15e4d (diff)
downloadcmd2-git-08cee23ec10f22da1eb54944c8e01564c16a5c33.tar.gz
Attempt at fixing some extraneous output on Linux when using Python3 and xclip
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py7
1 files changed, 6 insertions, 1 deletions
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: