From 1d6ac5dd1f4d7c99892521e31b15ffa497946c60 Mon Sep 17 00:00:00 2001 From: Anton Derbenev Date: Tue, 14 Jul 2015 13:42:13 -0400 Subject: [PATCH 1/3] error on no --pv-list file --- arget | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arget b/arget index 3b8d795..23bad14 100755 --- a/arget +++ b/arget @@ -107,7 +107,11 @@ if opt.pvlist: if opt.pvlist == '-': AF = sys.stdin else: - AF = open(opt.pvlist, 'r') + try: + AF = open(opt.pvlist, 'r') + except IOError: + print "--pv-list: No such file or directory: '%s'"%opt.pvlist + sys.exit(0) args += filter(lambda L:len(L) and L[0]!='#', map(str.rstrip, AF.readlines())) if opt.pvlist != '-': AF.close() From 6c63a5dc5c23a5353aef6b43e84a5fc3b4aba222 Mon Sep 17 00:00:00 2001 From: Anton Derbenev Date: Tue, 14 Jul 2015 18:35:07 -0400 Subject: [PATCH 2/3] return code non-zero on missing --pv-list file --- arget | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arget b/arget index 23bad14..91ab139 100755 --- a/arget +++ b/arget @@ -111,7 +111,7 @@ if opt.pvlist: AF = open(opt.pvlist, 'r') except IOError: print "--pv-list: No such file or directory: '%s'"%opt.pvlist - sys.exit(0) + sys.exit(1) args += filter(lambda L:len(L) and L[0]!='#', map(str.rstrip, AF.readlines())) if opt.pvlist != '-': AF.close() From 8acb14a39e95eb408dcb9c6d12d06d4eddcebe8c Mon Sep 17 00:00:00 2001 From: Anton Derbenev Date: Thu, 16 Jul 2015 18:47:12 -0400 Subject: [PATCH 3/3] More fitting return code --- arget | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arget b/arget index 91ab139..978874c 100755 --- a/arget +++ b/arget @@ -111,7 +111,13 @@ if opt.pvlist: AF = open(opt.pvlist, 'r') except IOError: print "--pv-list: No such file or directory: '%s'"%opt.pvlist - sys.exit(1) + ret = 1 + try: + from os import EX_NOINPUT # Platform-specific + ret = EX_NOINPUT + except ImportError: + pass + sys.exit(ret) args += filter(lambda L:len(L) and L[0]!='#', map(str.rstrip, AF.readlines())) if opt.pvlist != '-': AF.close()