From 78bcd313a2046baee636f6a8a46d69aead454451 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Sun, 24 Mar 2024 00:33:50 +0800 Subject: [PATCH] bc: regression on old perl (#511) * bc: regression on old perl * The default mode of this bc is not bc at all because it is not arbitrary precision; numbers are just perl floating point values * It's still useful enough as a basic calculator but probably the program should be rewritten * For fun I booted DamnSmallLinux live-cd v4.4.10 * The version of perl on this old linux doesn't include Math::BigFloat * bc would not load, even in default mode because of a "use" statement; lazy-load with "require" avoids the error * Simplify error message if BigFloat is missing Normally this would be present but possibly a perl was built without it. --- bin/bc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/bc b/bin/bc index c41bfb95..68869d03 100755 --- a/bin/bc +++ b/bin/bc @@ -2034,10 +2034,10 @@ sub command_line() while (@ARGV) { my $f = shift @ARGV; if ($f eq '-b') { - use Math::BigFloat; + eval { require Math::BigFloat } or die "This program requires the Math::BigFloat module\n"; $bignum = 1; } elsif ($f eq '-d') { - use Data::Dumper; + eval { require Data::Dumper } or die "This program requires the Data::Dumper module\n"; $debug = 1; } elsif ($f eq '-y') { $yydebug = 1;