]> git.proxmox.com Git - pve-installer.git/commitdiff
run env: use default error message if country detection failed with empty string master
authorChristoph Heiss <c.heiss@proxmox.com>
Tue, 26 Mar 2024 13:29:19 +0000 (14:29 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 8 Apr 2024 16:02:26 +0000 (18:02 +0200)
Bit of perl fun again.
$err from detect_country_tracing_to() can be empty string under certain
circumstances (according to a forum post [0]). The // operator
evaluates an empty as true, thus `warn` receives an empty string to and
just prints

  Warning: something wrong at /usr/share/perl5/proxmox/Install/RunEnv.pm line 305

Which isn't particular helpful. Use the || operator instead, that
evaluates an empty string as false and thus would fall back to the
generic error message.

A minimal reproducer/example for completeness sake:

  #!/usr/bin/env perl
  use strict;
  use warnings;

  warn ('' // "unable to detect country\n");
  warn ('' || "unable to detect country\n");

gives

  Warning: something's wrong at ./test.pl line 5.
  unable to detect country

[0] https://forum.proxmox.com/threads/blank-screen-while-installing.143928/

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Proxmox/Install/RunEnv.pm

index 25b6bb3db25a648328ac69f321e84c93ca895fd8..39505d08e9856aa28906d818a2aa332e33d2ac13 100644 (file)
@@ -302,7 +302,7 @@ sub query_installation_environment : prototype() {
     if (defined($country)) {
        $output->{country} = $country;
     } else {
-       warn ($err // "unable to detect country\n");
+       warn ($err || "unable to detect country\n");
     }
 
     return $output;