aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2016-12-09 12:10:53 +0100
committerVG <vg@devys.org>2016-12-09 12:10:53 +0100
commitf0e69d196e8733fe888aa5f18d6aeca11a79e739 (patch)
tree645a8f090f94a2d40f0f8921df1df8c1ed5c5abb
parentf942001c3eea6fedb838ebf22720ab507c77e192 (diff)
downloadclip-f0e69d196e8733fe888aa5f18d6aeca11a79e739.tar.gz
clip-f0e69d196e8733fe888aa5f18d6aeca11a79e739.tar.bz2
clip-f0e69d196e8733fe888aa5f18d6aeca11a79e739.zip
fix first and empty use case
-rwxr-xr-xclip8
1 files changed, 6 insertions, 2 deletions
diff --git a/clip b/clip
index 29e73e3..f61b751 100755
--- a/clip
+++ b/clip
@@ -52,8 +52,12 @@ if __name__ == '__main__':
clipboard_filepath = '/dev/shm/%s-clipboard' % getpass.getuser()
if(sys.stdin.isatty()):
# Should write clipboard contents out to stdout
- with secure_open(clipboard_filepath, 'rb') as fo:
- sys.stdout.buffer.write(fo.read())
+ try:
+ with secure_open(clipboard_filepath, 'rb') as fo:
+ sys.stdout.buffer.write(fo.read())
+ except FileNotFoundError:
+ # equivalent to an empty file
+ pass
elif(sys.stdout.isatty()):
# Should save stdin to clipboard
with secure_open(clipboard_filepath, 'wb') as fo: