From aa0c168332b81f020df58dbea04a665dc2a90081 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Wed, 11 Oct 2017 16:49:10 +0000 Subject: [PATCH] Set PCRE2GREP_RC to the pcre2grep exit status when running under VMS. --- ChangeLog | 4 ++++ src/pcre2grep.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 998030e..c027c92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,10 @@ the public names in pcre2_convert.c. 8. Added two casts to compile.c and one to match.c to avoid compiler warnings. +9. Added code to pcre2grep when compiled under VMS to set the symbol +PCRE2GREP_RC to the exit status, because VMS does not distinguish between +exit(0) and exit(1). + Version 10.30 14-August-2017 ---------------------------- diff --git a/src/pcre2grep.c b/src/pcre2grep.c index fcd5f12..bd86998 100644 --- a/src/pcre2grep.c +++ b/src/pcre2grep.c @@ -520,6 +520,22 @@ Returns: does not return static void pcre2grep_exit(int rc) { +/* VMS does exit codes differently: both exit(1) and exit(0) return with a +status of 1, which is not helpful. To help with this problem, define a symbol +(akin to an environment variable) called "PCRE2GREP_RC" and put the exit code +therein. */ + +#ifdef __VMS +#include descrip +#include lib$routines + char val_buf[4]; + $DESCRIPTOR(sym_nam, "PCRE2GREP_RC"); + $DESCRIPTOR(sym_val, val_buf); + sprintf(val_buf, "%d", rc); + sym_val.dsc$w_length = strlen(val_buf); + lib$set_symbol(&sym_nam, &sym_val); +#endif + if (resource_error) { fprintf(stderr, "pcre2grep: Error %d, %d, %d or %d means that a resource "