From 7e146d8a9d604df5215700aaa3c3695371cdf99b Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Sun, 13 Dec 2020 15:34:03 +0700 Subject: [PATCH] remove #! from beginning of loaded files to support use in shell scripts --- src/Evaller.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Evaller.php b/src/Evaller.php index ac5f845..a1cbe67 100644 --- a/src/Evaller.php +++ b/src/Evaller.php @@ -322,6 +322,11 @@ class Evaller $input = @file_get_contents($targetFile); + // Remove #! from the beginning that is used by shell scripts + if (extension_loaded('pcre')) { + $input = preg_replace('/^#![^\n\r]*[\n\r]+/', '', $input, 1); + } + // Wrap input in a do to process multiple expressions $input = "(do $input)";