summaryrefslogtreecommitdiff
path: root/Debian/Dgit/ExitStatus.pm
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2018-06-16 13:41:00 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-06-16 22:40:13 +0100
commit1d6ce76f63bcbe787e7184a1fa5aa568a2a18873 (patch)
tree403ea63d308c48c3657caaa36549b12ee1dcb1f3 /Debian/Dgit/ExitStatus.pm
parent6b3cdcf0d595efd96bc8c4220df87f7fd5aaef76 (diff)
exit status: Introdude Debian::Dgit::ExitStatus
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>
Diffstat (limited to 'Debian/Dgit/ExitStatus.pm')
-rw-r--r--Debian/Dgit/ExitStatus.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/Debian/Dgit/ExitStatus.pm b/Debian/Dgit/ExitStatus.pm
new file mode 100644
index 0000000..b69d42d
--- /dev/null
+++ b/Debian/Dgit/ExitStatus.pm
@@ -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;