From 6978c6d8ad828716109b04ba707f0909c0b72636 Mon Sep 17 00:00:00 2001 From: Muntasir Mallick Date: Thu, 1 Feb 2018 16:37:34 -0500 Subject: [PATCH] [z/OS] Skip character conversion for ASCII streams When applications are invoked with execFile the executable name is passed as an absolute path to the Node runtime, in order to detect if its an ascii application we need to strip the path and extract the application name --- src/process_wrap.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 47904b143779..47803d4b5701 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -5,6 +5,7 @@ #include #include +#include #ifdef __MVS__ #include // e2a #endif @@ -65,12 +66,22 @@ class ProcessWrap : public HandleWrap { AsyncWrap::PROVIDER_PROCESSWRAP) { } - static bool isAsciiPgm(const char *pgmName) { - const char * AsciiPgms[2] = { "git", "python"}; + static bool isAsciiPgm(const char *pgm) { + const char * pgmName = pgm; + const char * AsciiPgms[2] = { "git", "python2"}; + std::cmatch cm; + std::regex absolutePath("^.*\/([^/]*)$"); + if (std::regex_match(pgmName,cm,absolutePath)) { + pgmName = cm[1].str().c_str(); + if (cm.size() > 2) { + return false; + } + } + for (int pgId = 0 ; pgId < 2; pgId++) { - if (strcmp(AsciiPgms[pgId],pgmName) == 0) { - return true; - } + if (strcmp(pgmName,AsciiPgms[pgId]) == 0) { + return true; + } } return false; }