chiark / gitweb /
exit status: Introdude Debian::Dgit::ExitStatus
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 12:41:00 +0000 (13:41 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 21:40:13 +0000 (22:40 +0100)
No callers yet.

Also, no version for dgit-infrastructure.  The one perl script in
dgit-infrastructure that cares a lot about its exit status
(dgit-repos-policy-debian) already has an END { } and uses _exit,
which is a bit like our approach here, but simpler.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit/ExitStatus.pm [new file with mode: 0644]
Makefile

diff --git a/Debian/Dgit/ExitStatus.pm b/Debian/Dgit/ExitStatus.pm
new file mode 100644 (file)
index 0000000..b69d42d
--- /dev/null
@@ -0,0 +1,26 @@
+# -*- perl -*-
+
+package Debian::Dgit::ExitStatus;
+
+# To use this, at the top (before use strict, even):
+#
+#   END { $? = $Debian::Dgit::ExitStatus::desired // -1; };
+#   use Debian::Dgit::ExitStatus;
+#
+# and then replace every call to `exit' with `finish'.
+# Add a `finish 0' to the end of the program.
+
+BEGIN {
+    use Exporter;
+    @ISA = qw(Exporter);
+    @EXPORT = qw(finish $desired);
+}
+
+our $desired;
+
+sub finish ($) {
+    $desired = $_[0] // 0;
+    exit $desired;
+}
+
+1;
index 2e47c0bbcad1245d6873ab37349143f896477204..21ccc1b79765fb0fa40856b3bcd8613d3cdc1de3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ MAN7PAGES=dgit.7                              \
        dgit-sponsorship.7
 
 TXTDOCS=README.dsc-import
-PERLMODULES=Debian/Dgit.pm
+PERLMODULES=Debian/Dgit.pm Debian/Dgit/ExitStatus.pm
 ABSURDITIES=git
 
 INFRA_PROGRAMS=dgit-repos-server dgit-ssh-dispatch \