From f0e69d196e8733fe888aa5f18d6aeca11a79e739 Mon Sep 17 00:00:00 2001 From: VG Date: Fri, 9 Dec 2016 12:10:53 +0100 Subject: fix first and empty use case --- clip | 8 ++++++-- 1 file 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: -- cgit v1.2.3