]> git.proxmox.com Git - pve-installer.git/commit
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)
commit176b7be680e6d4b66d4dd5c448f5dd820c5c86a5
tree4616b580b08e95100dfa9551c93f4fdb4cd1fb01
parentdb8fe71b259dd7f1cf713de0f97295924f9ba2cb
run env: use default error message if country detection failed with empty string

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