diff options
author | Jim Meyering <jim@meyering.net> | 2005-03-27 08:40:30 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-03-27 08:40:30 +0000 |
commit | ae95bdc5e77ccb2e6df1a40e6b7363b8fd5a722f (patch) | |
tree | 7c01419cf4c4eef0d0088b004c2dfd83776d1519 /src/wheel-gen.pl | |
parent | e2b271d81d32e20310a704d26efe1bb79c81fb73 (diff) | |
download | coreutils-ae95bdc5e77ccb2e6df1a40e6b7363b8fd5a722f.tar.xz |
Use the same global destructor as dcgen.
Diffstat (limited to 'src/wheel-gen.pl')
-rwxr-xr-x | src/wheel-gen.pl | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/wheel-gen.pl b/src/wheel-gen.pl index be03a6e3b..ec4dd6198 100755 --- a/src/wheel-gen.pl +++ b/src/wheel-gen.pl @@ -1,19 +1,20 @@ #!/usr/bin/perl -w -# -*- perl -*- eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' - if 0; + if 0; use strict; -(my $program_name = $0) =~ s|.*/||; +(my $ME = $0) =~ s|.*/||; +# A global destructor to close standard output with error checking. sub END { - use POSIX qw (_exit); - # This is required if the code might send any output to stdout - # E.g., even --version or --help. So it's best to do it unconditionally. + defined fileno STDOUT + or return; close STDOUT - or (warn "$program_name: closing standard output: $!\n"), _exit (1); + and return; + warn "$ME: closing standard output: $!\n"; + $? ||= 1; } sub is_prime ($) @@ -41,7 +42,7 @@ sub is_prime ($) { @ARGV == 1 - or die "$program_name: missing argument\n"; + or die "$ME: missing argument\n"; my $wheel_size = $ARGV[0]; |