From c82b72d8aaea0f0b04a19fa18d0765d7476ab217 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 21 Feb 2021 00:30:14 -0600 Subject: [PATCH] [nostalgia/scripts/pybb] Make gracefully exit upon Ctl-C --- scripts/pybb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/pybb b/scripts/pybb index 26cedd66..e30894ec 100644 --- a/scripts/pybb +++ b/scripts/pybb @@ -5,10 +5,10 @@ import os import shutil -import stat import subprocess import sys + def mkdir(path): if not os.path.exists(path) and os.path.isdir(path): os.mkdir(path) @@ -29,7 +29,7 @@ def cmake_build(base_path, target): if err != 0: sys.exit(err) -if __name__ == '__main__': +def main(): if sys.argv[1] == 'mkdir': mkdir(sys.argv[2]) elif sys.argv[1] == 'rm': @@ -37,3 +37,10 @@ if __name__ == '__main__': rm(sys.argv[i]) elif sys.argv[1] == 'cmake-build': cmake_build(sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None) + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + sys.exit(1) +