From: Alexander Schmidt Date: Sat, 3 Oct 2020 19:24:32 +0000 (+0200) Subject: exit on missing argument X-Git-Url: http://git.treefish.org/~alex/mtxbot.git/commitdiff_plain/c4b302f9d8c02035bc4f45458a33bb9e9ba26935?ds=inline exit on missing argument --- diff --git a/src/mtxbot-post.py b/src/mtxbot-post.py index 1ba56c4..3673eda 100755 --- a/src/mtxbot-post.py +++ b/src/mtxbot-post.py @@ -11,17 +11,18 @@ assert sys.version_info >= (3, 5) if len(sys.argv) != 2: print("Usage: %s " % sys.argv[0]) + sys.exit(1) fifo_dir = os.getenv('MTXBOT_FIFO_DIR', '/run/mtxbot') fifo_path = "%s/%s" % (fifo_dir, sys.argv[1]) if not os.path.isdir(fifo_dir): print("Fifo directory %s does not exist!" % fifo_dir, file=sys.stderr) - sys.exit(1) + sys.exit(2) if not stat.S_ISFIFO( os.stat(fifo_path).st_mode ): print("Channel %s does not exist!" % sys.argv[1], file=sys.stderr) - sys.exit(2) + sys.exit(3) for i in range(0, 10): fifo = -1 @@ -37,4 +38,4 @@ for i in range(0, 10): posix.close(fifo) print("Error posting to channel %s!" % sys.argv[1], file=sys.stderr) -sys.exit(3) +sys.exit(4)