From ca405f953b2951f7e62b2708c0f8394ac7cc7459 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Fri, 17 Apr 2026 22:27:36 +0200 Subject: [PATCH] add success check to file writing --- scripts/runner.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/runner.pl b/scripts/runner.pl index dd225c9..7cfc703 100644 --- a/scripts/runner.pl +++ b/scripts/runner.pl @@ -46,7 +46,7 @@ sub update_db_config { my @lines; my $found = 0; while ( my $line = <$readhandle> ) { - if ( $line =~ /^database=/ ) { + if ( rindex( $line, "database=", 0 ) == 0 ) { $line = "database=${db_prefix}_$experiment\n"; $found = 1; } @@ -54,13 +54,16 @@ sub update_db_config { } close($readhandle) or die "failed to close db.conf: $!"; + say "Sanity check:"; + say @lines; + die "no database= line found in $remote_db_conf for some reason" unless $found; open( my $writehandle, '>', $remote_db_conf ) or die "failed to open db.conf: $!"; - print( $writehandle, @lines ); - close($writehandle) or die "failed to close db.conf: $!"; + print( $writehandle, @lines ) or die "failed to write db.conf: $!"; + close($writehandle) or die "failed to close db.conf: $!"; say "Updated db.conf for database $db_prefix\_$experiment"; }