From: Richard Henderson Date: Fri, 26 May 2023 17:22:51 +0000 (-0700) Subject: decodetree: Do not remove output_file from /dev X-Git-Tag: v8.1.0-rc0~85^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=036cc75ca0bff26bfe75dc721e641d812cad3c09;p=thirdparty%2Fqemu.git decodetree: Do not remove output_file from /dev Nor report any PermissionError on remove. The primary purpose is testing with -o /dev/null. Signed-off-by: Richard Henderson --- diff --git a/scripts/decodetree.py b/scripts/decodetree.py index e4ef0a03cc4..a9a0cd0fa3a 100644 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -71,7 +71,12 @@ def error_with_file(file, lineno, *args): if output_file and output_fd: output_fd.close() - os.remove(output_file) + # Do not try to remove e.g. -o /dev/null + if not output_file.startswith("/dev"): + try: + os.remove(output_file) + except PermissionError: + pass exit(0 if testforerror else 1) # end error_with_file