perl version oddity
[exim.git] / src / src / exim_checkaccess.src
index 8169243bf585a953667dee755491e40894f9dec7..9615443db65274c12082b5ecb9754f40593eaffd 100755 (executable)
@@ -1,8 +1,9 @@
 #! /bin/sh
-# $Cambridge: exim/src/src/exim_checkaccess.src,v 1.1 2004/10/07 10:39:01 ph10 Exp $
 
-# Copyright (c) 2002 University of Cambridge.
+# Copyright (c) The Exim Maintainers 2023
+# Copyright (c) University of Cambridge, 1995 - 2007
 # See the file NOTICE for conditions of use and distribution.
+# SPDX-License-Identifier: GPL-2.0-or-later
 
 # Except when they appear in comments, the following placeholders in this
 # source are replaced when it is turned into a runnable script:
@@ -52,8 +53,7 @@ done
 # a nasty tendency to get lost in the past. Use a variable to hold a space and
 # a tab to keep the tab in one place.
 
-st='    '
-exim_path=`grep "^[$st]*exim_path" $config | sed "s/.*=[$st]*//"`
+exim_path=`perl -ne 'chop;if (/^\s*exim_path\s*=\s*(.*)/){print "$1\n";last;}' $config`
 if test "$exim_path" = ""; then exim_path=BIN_DIRECTORY/exim; fi
 
 
@@ -65,9 +65,18 @@ if test "$exim_path" = ""; then exim_path=BIN_DIRECTORY/exim; fi
 
 PERL_COMMAND - $exim_path $args <<'End'
 
+BEGIN { pop @INC if $INC[-1] eq '.' };
 use FileHandle;
+use File::Basename;
 use IPC::Open2;
 
+if ($ARGV[0] eq '--version' || $ARGV[0] eq '-v') {
+    print basename($0) . ": $0\n",
+          "build: EXIM_RELEASE_VERSIONEXIM_VARIANT_VERSION\n",
+          "perl(runtime): $]\n";
+    exit 0;
+}
+
 if (scalar(@ARGV) < 3)
   {
   print "Usage: exim_checkaccess <IP address> <email address> [exim options]\n";