From 9aa3f053d705502e60a5167afedbbcfe1d36cded Mon Sep 17 00:00:00 2001 From: Mads Ravn Date: Sun, 9 Apr 2023 22:50:42 +0200 Subject: [PATCH 1/2] './configure' now checks if 'config.toml' exists before writing to that destination --- src/bootstrap/configure.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index abd28b4005d0b..716077adc754f 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -521,6 +521,10 @@ def write_config_toml(writer, section_order, targets, sections): else: writer = write_uncommented(sections[section], writer) +def quit_if_file_exists(file): + if os.path.isfile(file): + p("Existing '" + file + "' detected. EXITING") + quit() if __name__ == "__main__": p("processing command line") @@ -528,6 +532,8 @@ def write_config_toml(writer, section_order, targets, sections): # TOML we're going to write out p("") section_order, sections, targets = parse_args(sys.argv[1:]) + # If 'config.toml' already exists, exit the script at this point + quit_if_file_exists('config.toml') # Now that we've built up our `config.toml`, write it all out in the same # order that we read it in. From 010d7975d61b7437ef26d8e08f70afde2cb5e85a Mon Sep 17 00:00:00 2001 From: Mads Ravn Date: Wed, 19 Apr 2023 14:58:53 +0200 Subject: [PATCH 2/2] Changing position of early exit and using standard error method with correct exit code --- src/bootstrap/configure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 716077adc754f..782bb6cf36f37 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -523,17 +523,17 @@ def write_config_toml(writer, section_order, targets, sections): def quit_if_file_exists(file): if os.path.isfile(file): - p("Existing '" + file + "' detected. EXITING") - quit() + err("Existing '" + file + "' detected.") if __name__ == "__main__": + # If 'config.toml' already exists, exit the script at this point + quit_if_file_exists('config.toml') + p("processing command line") # Parse all known arguments into a configuration structure that reflects the # TOML we're going to write out p("") section_order, sections, targets = parse_args(sys.argv[1:]) - # If 'config.toml' already exists, exit the script at this point - quit_if_file_exists('config.toml') # Now that we've built up our `config.toml`, write it all out in the same # order that we read it in.