From f9c9277567d27143fe81dc4f4fb79ed12c044617 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 13:33:10 +0200 Subject: [PATCH 01/22] Escape backslash too Signed-off-by: Martin Zeithaml --- test/environments.sh | 39 +++++++++++++++++++ test/fakeRuntime/schemas/server-common.json | 14 +++++++ .../fakeRuntime/schemas/zowe-yaml-schema.json | 13 +++++++ 3 files changed, 66 insertions(+) create mode 100755 test/environments.sh create mode 100644 test/fakeRuntime/schemas/server-common.json create mode 100644 test/fakeRuntime/schemas/zowe-yaml-schema.json diff --git a/test/environments.sh b/test/environments.sh new file mode 100755 index 0000000..db9182e --- /dev/null +++ b/test/environments.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# This program and the accompanying materials are +# made available under the terms of the Eclipse Public License v2.0 which accompanies +# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html +# +# SPDX-License-Identifier: EPL-2.0 +# +# Copyright Contributors to the Zowe Project. + +# --------------------------------------------------- +# Start with any paramter -> prints Launcher's output +# --------------------------------------------------- + +print= + +if [ ! -z "${1}" ]; then + print='1' +fi + +LAUNCHER='../bin/zowe_launcher' +ZOWE_YAML="./files/zowe.environments.yaml" + +LAUNCHER_OUTPUT= +export ZLDEBUG='ON' +export CONFIG="FILE(${ZOWE_YAML})" + +if [ ! -z "${print}" ]; then + "${LAUNCHER}" "ha1" +fi + +LAUNCHER_OUTPUT=$("${LAUNCHER}" "ha1" 2>&1 | grep 'DEBUG shared env pos1') + +printf "%s\n\n" "${LAUNCHER_OUTPUT}" + +printf "${ZOWE_YAML} TEST_VAR*:\n" +cat "${ZOWE_YAML}" | grep TEST_VAR + +exit 0 diff --git a/test/fakeRuntime/schemas/server-common.json b/test/fakeRuntime/schemas/server-common.json new file mode 100644 index 0000000..5b9cbb2 --- /dev/null +++ b/test/fakeRuntime/schemas/server-common.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://zowe.org/schemas/v2/server-common", + "title": "Common types", + "description": "Simplified version for testing", + "$defs": { + "semverVersion": { + "$anchor": "zoweSemverVersion", + "type": "string", + "description": "A semantic version, see https://semver.org/", + "pattern": "^[0-9]*\\.[0-9]*\\.[0-9]*(-*[a-zA-Z][0-9a-zA-Z\\-\\.]*)?(\\+[0-9a-zA-Z\\-\\.]*)?$" + } + } +} diff --git a/test/fakeRuntime/schemas/zowe-yaml-schema.json b/test/fakeRuntime/schemas/zowe-yaml-schema.json new file mode 100644 index 0000000..ea0b068 --- /dev/null +++ b/test/fakeRuntime/schemas/zowe-yaml-schema.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://zowe.org/schemas/v2/server-base", + "title": "Zowe configuration file", + "description": "Simplified version for testing", + "type": "object", + "additionalProperties": false, + "properties": { + "zowe": { + "type": "object" + } + } +} From b4f640cfaae34b3855a5a7a3afb8e6a2b8e3322b Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 13:34:33 +0200 Subject: [PATCH 02/22] Typo Signed-off-by: Martin Zeithaml --- test/config-syntax.sh | 2 +- test/environments.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/config-syntax.sh b/test/config-syntax.sh index d5859bd..63992ce 100755 --- a/test/config-syntax.sh +++ b/test/config-syntax.sh @@ -8,7 +8,7 @@ # # Copyright Contributors to the Zowe Project. -# Start with_any_paramter -> prints output (diff style) +# Start with any parameter -> prints output (diff style) # rc of this = number of errors found print= diff --git a/test/environments.sh b/test/environments.sh index db9182e..6e445d4 100755 --- a/test/environments.sh +++ b/test/environments.sh @@ -9,7 +9,7 @@ # Copyright Contributors to the Zowe Project. # --------------------------------------------------- -# Start with any paramter -> prints Launcher's output +# Start with any parameter -> prints Launcher's output # --------------------------------------------------- print= From 5c16b7a148674fa0ec736bc7ce22895a8aa3bfe8 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 13:39:02 +0200 Subject: [PATCH 03/22] Code change Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 7 +++++-- src/main.c | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ca9a70..55c2575 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,16 @@ All notable changes to the Zowe Launcher package will be documented in this file. This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section. -## 3.3 +## 3.4.0 +- Bugfix: Escape backslash when used in environment variable ([#1??]https://github.com/zowe/launcher/pull/1??) + +## 3.3.0 - Bugfix: `zowe.sysMessages` feature was ignoring messages where the matching string was after the position of 126 ([#157]https://github.com/zowe/launcher/pull/157) - Enhancement: Launcher can now accept PARMLIB CONFIG entries that have more than one member name ([#146](https://github.com/zowe/launcher/pull/146)) - Enhancement: Trimming the sys messages to print from the sys-message-id as optional based on the zowe.sysMessageTrim=true/false. (#147) - Enhancement: Avoid starting individual apiml components when apiml modulith is enabled ([#160](https://github.com/zowe/launcher/pull/160)) -## 3.1 +## 3.1.0 - Bugfix: HEAPPOOLS and HEAPPOOLS64 no longer need to be set to OFF for launcher (#133) ## 2.17.0 diff --git a/src/main.c b/src/main.c index 032b7f3..5608a05 100644 --- a/src/main.c +++ b/src/main.c @@ -436,15 +436,19 @@ static bool arrayListContains(ArrayList *list, char *element) { static char* escape_string(char *input) { int length = strlen(input); int quotes = 0; + int backSlashes = 0; for (int i = 0; i < length; i++) { if (input[i] == '\"') quotes++; + if (input[i] == '\\') backSlashes++; } - char *output = malloc(length + quotes + 2 + 1); // add quote on first and the last position and escape quotes inside + // 2 + 1 = add quote on first and the last position and \0 at the end + // quotes & backSlashes = add '\' to escape '"' and '\' + char *output = malloc(length + quotes + backSlashes + 2 + 1); output[0] = '\"'; int j = 1; for (int i = 0; i < length; i++) { - if (input[i] == '\"') { + if (input[i] == '\"' || input[i] == '\\') { output[j++] = '\\'; } output[j++] = input[i]; From aad3151ab3e7f24d99c127d32a71a77a8076ab69 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 13:40:39 +0200 Subject: [PATCH 04/22] PR number update in CHLOG Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c2575..de516ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe Launcher package will be documented in this file This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section. ## 3.4.0 -- Bugfix: Escape backslash when used in environment variable ([#1??]https://github.com/zowe/launcher/pull/1??) +- Bugfix: Escape backslash when used in environment variable ([#168]https://github.com/zowe/launcher/pull/168) ## 3.3.0 - Bugfix: `zowe.sysMessages` feature was ignoring messages where the matching string was after the position of 126 ([#157]https://github.com/zowe/launcher/pull/157) From 426641a57180d9e69d3dbcd345b4d5b13aa911ab Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 13:42:02 +0200 Subject: [PATCH 05/22] Minor formatting changes Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de516ab..3019c48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,10 @@ All notable changes to the Zowe Launcher package will be documented in this file This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section. ## 3.4.0 -- Bugfix: Escape backslash when used in environment variable ([#168]https://github.com/zowe/launcher/pull/168) +- Bugfix: Escape backslash when used in environment variable ([#168](https://github.com/zowe/launcher/pull/168)) ## 3.3.0 -- Bugfix: `zowe.sysMessages` feature was ignoring messages where the matching string was after the position of 126 ([#157]https://github.com/zowe/launcher/pull/157) +- Bugfix: `zowe.sysMessages` feature was ignoring messages where the matching string was after the position of 126 ([#157](https://github.com/zowe/launcher/pull/157)) - Enhancement: Launcher can now accept PARMLIB CONFIG entries that have more than one member name ([#146](https://github.com/zowe/launcher/pull/146)) - Enhancement: Trimming the sys messages to print from the sys-message-id as optional based on the zowe.sysMessageTrim=true/false. (#147) - Enhancement: Avoid starting individual apiml components when apiml modulith is enabled ([#160](https://github.com/zowe/launcher/pull/160)) From 925237d87621d60a5d64a7c5e5a23c7af6f17f96 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 14:00:40 +0200 Subject: [PATCH 06/22] Config for testing Signed-off-by: Martin Zeithaml --- test/files/zowe.environments.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/files/zowe.environments.yaml diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml new file mode 100644 index 0000000..37febce --- /dev/null +++ b/test/files/zowe.environments.yaml @@ -0,0 +1,24 @@ +zowe: + environments: + + TEST_VAR01: 'TE\"ST' # "TE\\\"ST" + TEST_VAR02: "TE\"ST" # "TE\"ST" + TEST_VAR03: TE\"ST # "TE\\\"ST" + TEST_VAR04: # + TEST_VAR05: ~ # + TEST_VAR06: true # true + TEST_VAR07: \\\\\\\\\\ # "\\\\\\\\\\\\\\\\\\\\" + TEST_VAR08: '""""""""""' # "\"\"\"\"\"\"\"\"\"\"" + TEST_VAR09: '"' # "\"" + TEST_VAR10: 123456 # 123456 + TEST_VAR11: \n # "\\n" + TEST_VAR12: \0 # "\\0" + + runtimeDirectory: "${{ () => { + let thisPath = os.realpath('./fakeRuntime'); + if (thisPath[1] == 0) { + return thisPath[0]; + } + return undefined; + } () + }}" From b8a4612da30d287310cdd27ae7c34c14a5fd1056 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 14:22:59 +0200 Subject: [PATCH 07/22] Grep update Signed-off-by: Martin Zeithaml --- test/environments.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/environments.sh b/test/environments.sh index 6e445d4..5b0dec0 100755 --- a/test/environments.sh +++ b/test/environments.sh @@ -29,7 +29,7 @@ if [ ! -z "${print}" ]; then "${LAUNCHER}" "ha1" fi -LAUNCHER_OUTPUT=$("${LAUNCHER}" "ha1" 2>&1 | grep 'DEBUG shared env pos1') +LAUNCHER_OUTPUT=$("${LAUNCHER}" "ha1" 2>&1 | grep "DEBUG shared env pos.*TEST_VAR.*") printf "%s\n\n" "${LAUNCHER_OUTPUT}" From 8ca35246e54c0d2fb9689af397ab1172248f4665 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 14:58:17 +0200 Subject: [PATCH 08/22] More test cases Signed-off-by: Martin Zeithaml --- test/environments.sh | 7 +++--- test/files/zowe.environments.yaml | 38 +++++++++++++++++++------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/test/environments.sh b/test/environments.sh index 5b0dec0..7fa1173 100755 --- a/test/environments.sh +++ b/test/environments.sh @@ -29,11 +29,10 @@ if [ ! -z "${print}" ]; then "${LAUNCHER}" "ha1" fi -LAUNCHER_OUTPUT=$("${LAUNCHER}" "ha1" 2>&1 | grep "DEBUG shared env pos.*TEST_VAR.*") - +# awk prints between TEST_VAR_START= and TEST_VAR_END= +LAUNCHER_OUTPUT=$("${LAUNCHER}" "ha1" 2>&1 | awk '/TEST_VAR_START=/{flag=1}/TEST_VAR_END=/{print; flag=0}flag') printf "%s\n\n" "${LAUNCHER_OUTPUT}" -printf "${ZOWE_YAML} TEST_VAR*:\n" -cat "${ZOWE_YAML}" | grep TEST_VAR +awk '/TEST_VAR_START/{flag=1}/TEST_VAR_END/{print; flag=0}flag' "${ZOWE_YAML}" exit 0 diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml index 37febce..328ab70 100644 --- a/test/files/zowe.environments.yaml +++ b/test/files/zowe.environments.yaml @@ -1,19 +1,29 @@ zowe: environments: - - TEST_VAR01: 'TE\"ST' # "TE\\\"ST" - TEST_VAR02: "TE\"ST" # "TE\"ST" - TEST_VAR03: TE\"ST # "TE\\\"ST" - TEST_VAR04: # - TEST_VAR05: ~ # - TEST_VAR06: true # true - TEST_VAR07: \\\\\\\\\\ # "\\\\\\\\\\\\\\\\\\\\" - TEST_VAR08: '""""""""""' # "\"\"\"\"\"\"\"\"\"\"" - TEST_VAR09: '"' # "\"" - TEST_VAR10: 123456 # 123456 - TEST_VAR11: \n # "\\n" - TEST_VAR12: \0 # "\\0" - + TEST_VAR_START: \S\T\A\R\T # "\\S\\T\\A\\R\\T" + TEST_VAR01: 'TE\"ST' # "TE\\\"ST" + TEST_VAR02: "TE\"ST" # "TE\"ST" + TEST_VAR03: TE\"ST # "TE\\\"ST" + TEST_VAR04: # + TEST_VAR05: ~ # + TEST_VAR06: true # true + TEST_VAR07: \\\\\\\\\\ # "\\\\\\\\\\\\\\\\\\\\" + TEST_VAR08: '""""""""""' # "\"\"\"\"\"\"\"\"\"\"" + TEST_VAR09: '"' # "\"" + TEST_VAR10: 123456 # 123456 + TEST_VAR11: \n # "\\n" + TEST_VAR12: \0 # "\\0" + TEST_VAR13: # Array + - kiwi + - banana + - orange + TEST_VAR14: |- # William Shakespeare: All's Well That Ends Well + Love all, trust a few, + Do wrong to none: be able for thine enemy + Rather in power than use; and keep thy friend + Under thy own life's key: be check'd for silence, + But never tax'd for speech. + TEST_VAR_END: \E\N\D # "\\E\\N\\D" runtimeDirectory: "${{ () => { let thisPath = os.realpath('./fakeRuntime'); if (thisPath[1] == 0) { From 7f13d3de6a7ec929b93a0c1eeda748f1519f2cb7 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 15:11:12 +0200 Subject: [PATCH 09/22] Variable indentation Signed-off-by: Martin Zeithaml --- test/files/zowe.environments.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml index 328ab70..22fb4ef 100644 --- a/test/files/zowe.environments.yaml +++ b/test/files/zowe.environments.yaml @@ -23,7 +23,7 @@ zowe: Rather in power than use; and keep thy friend Under thy own life's key: be check'd for silence, But never tax'd for speech. - TEST_VAR_END: \E\N\D # "\\E\\N\\D" + TEST_VAR_END: \E\N\D # "\\E\\N\\D" runtimeDirectory: "${{ () => { let thisPath = os.realpath('./fakeRuntime'); if (thisPath[1] == 0) { From e849474fc0b31c9db7d12d078cd848e6284c05d0 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 25 Sep 2025 16:05:07 +0200 Subject: [PATCH 10/22] Yaml comment Signed-off-by: Martin Zeithaml --- test/files/zowe.environments.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml index 22fb4ef..2dc490f 100644 --- a/test/files/zowe.environments.yaml +++ b/test/files/zowe.environments.yaml @@ -1,5 +1,7 @@ zowe: environments: + # For sipmlification, keep TEST_VAR_START as the first + # and TEST_VAR_END as the last variable TEST_VAR_START: \S\T\A\R\T # "\\S\\T\\A\\R\\T" TEST_VAR01: 'TE\"ST' # "TE\\\"ST" TEST_VAR02: "TE\"ST" # "TE\"ST" From 850b2350e97e19e113b839b9ad633e937fe601a8 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 26 Sep 2025 09:37:35 +0200 Subject: [PATCH 11/22] More tests Signed-off-by: Martin Zeithaml --- src/main.c | 2 +- test/files/zowe.environments.yaml | 62 ++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/main.c b/src/main.c index 5608a05..6a78be1 100644 --- a/src/main.c +++ b/src/main.c @@ -468,7 +468,7 @@ static char* jsonToString(Json *json) { return jsonAsBoolean(json) ? "true" : "false"; case JSON_TYPE_NUMBER: case JSON_TYPE_INT64: - output = malloc(21); // Longest string possible -9223372036854775807 + output = malloc(21); // Longest string possible -9223372036854775808 (20+\0) snprintf(output, 21, "%ld", jsonAsInt64(json)); return output; case JSON_TYPE_DOUBLE: diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml index 2dc490f..4b657c3 100644 --- a/test/files/zowe.environments.yaml +++ b/test/files/zowe.environments.yaml @@ -1,31 +1,51 @@ zowe: environments: - # For sipmlification, keep TEST_VAR_START as the first - # and TEST_VAR_END as the last variable - TEST_VAR_START: \S\T\A\R\T # "\\S\\T\\A\\R\\T" - TEST_VAR01: 'TE\"ST' # "TE\\\"ST" - TEST_VAR02: "TE\"ST" # "TE\"ST" - TEST_VAR03: TE\"ST # "TE\\\"ST" - TEST_VAR04: # - TEST_VAR05: ~ # - TEST_VAR06: true # true - TEST_VAR07: \\\\\\\\\\ # "\\\\\\\\\\\\\\\\\\\\" - TEST_VAR08: '""""""""""' # "\"\"\"\"\"\"\"\"\"\"" - TEST_VAR09: '"' # "\"" - TEST_VAR10: 123456 # 123456 - TEST_VAR11: \n # "\\n" - TEST_VAR12: \0 # "\\0" - TEST_VAR13: # Array - - kiwi - - banana - - orange - TEST_VAR14: |- # William Shakespeare: All's Well That Ends Well + TEST_VAR_START: \S\T\A\R\T # "\\S\\T\\A\\R\\T" + # *** Bool *** + TEST_VAR_BOOL_01: true # true + TEST_VAR_BOOL_02: false # false + TEST_VAR_BOOL_03: !!bool true # true + TEST_VAR_BOOL_04: !!bool false # false + # *** Int *** + TEST_VAR_INT_01: 123456 # 123456 + TEST_VAR_INT_02: !!int 123456 # 123456 + TEST_VAR_INT_03: 0x7FFFFFFF # 2147483647 + TEST_VAR_INT_04: 0x00000001 # 1 + TEST_VAR_INT_05: !!int 0x7FFFFFFF # 2147483647 + TEST_VAR_INT_06: !!int 0x00000001 # 1 + TEST_VAR_INT_07: 9223372036854775807 # 9223372036854775807 + TEST_VAR_INT_08: !!int 9223372036854775807 # 9223372036854775807 + TEST_VAR_INT_09: -9223372036854775808 # -9223372036854775808 + TEST_VAR_INT_10: !!int -9223372036854775808 # -9223372036854775808 + # *** Str *** + TEST_VAR_STR_01: \\\\\\\\\\ # "\\\\\\\\\\\\\\\\\\\\" + TEST_VAR_STR_02: !!str \\\\\\\\\\ # "\\\\\\\\\\\\\\\\\\\\" + TEST_VAR_STR_03: '""""""""""' # "\"\"\"\"\"\"\"\"\"\"" + TEST_VAR_STR_04: '"' # "\"" + TEST_VAR_STR_05: \n # "\\n" + TEST_VAR_STR_06: \0 # "\\0" + TEST_VAR_STR_07: 'TE\"ST' # "TE\\\"ST" + TEST_VAR_STR_08: "TE\"ST" # "TE\"ST" + TEST_VAR_STR_09: TE\"ST # "TE\\\"ST" + TEST_VAR_STR_10: !!str 123 # "123" + TEST_VAR_STR_11: !!str true # "true" + TEST_VAR_STR_12: |- # William Shakespeare: All's Well That Ends Well Love all, trust a few, Do wrong to none: be able for thine enemy Rather in power than use; and keep thy friend Under thy own life's key: be check'd for silence, But never tax'd for speech. - TEST_VAR_END: \E\N\D # "\\E\\N\\D" + # *** Null *** + TEST_VAR_NULL_01: # + TEST_VAR_NULL_02: ~ # + TEST_VAR_NULL_03: null # + # *** Array *** + TEST_VAR_ARRAY_01: # Array + - kiwi + - banana + - orange + TEST_VAR_ARRAY_02: ['A', 'B', 'C'] # Array + TEST_VAR_END: \E\N\D # "\\E\\N\\D" runtimeDirectory: "${{ () => { let thisPath = os.realpath('./fakeRuntime'); if (thisPath[1] == 0) { From 9e7921dc5c013d085b52162e06ca81933f2ded68 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 26 Sep 2025 11:09:44 +0200 Subject: [PATCH 12/22] Test if launcher exist Signed-off-by: Martin Zeithaml --- test/config-syntax.sh | 5 +++++ test/environments.sh | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/test/config-syntax.sh b/test/config-syntax.sh index 63992ce..4746d32 100755 --- a/test/config-syntax.sh +++ b/test/config-syntax.sh @@ -19,6 +19,11 @@ if [ ! -z "${1}" ]; then fi LAUNCHER='../bin/zowe_launcher' +if [ ! -f "{LAUNCHER}" ]; then + echo "Executable \"${LAUNCHER}\" not found." + exit 1 +fi + ABS_PATH=$(cd .; pwd) TEST_FILES='./files' diff --git a/test/environments.sh b/test/environments.sh index 7fa1173..94bd27c 100755 --- a/test/environments.sh +++ b/test/environments.sh @@ -19,6 +19,11 @@ if [ ! -z "${1}" ]; then fi LAUNCHER='../bin/zowe_launcher' +if [ ! -f "{LAUNCHER}" ]; then + echo "Executable \"${LAUNCHER}\" not found." + exit 1 +fi + ZOWE_YAML="./files/zowe.environments.yaml" LAUNCHER_OUTPUT= From ada8daacb90f36324445df3a5eac358eacb51641 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 26 Sep 2025 14:48:42 +0200 Subject: [PATCH 13/22] Update readme Signed-off-by: Martin Zeithaml --- test/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/README.md b/test/README.md index 4e20bc4..9986bab 100644 --- a/test/README.md +++ b/test/README.md @@ -14,3 +14,7 @@ Copyright Contributors to the Zowe Project. Simple shell script to test basic functionality, such as treating items in environment variable `CONFIG`, `haInstace` and typical start-up messages. Return code is the number detected errors. To see an output, use any parameter, for example `./config-syntax.sh print`. + +## Environments + +Script for testing `zowe.environments`, especially escaping strings with `\` or `"`. See [config](./files/zowe.environments.yaml) used for testing. It will only print filtered output of Launcher and configuration. From 67044883403e148711d98b8365028573d8f07860 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 26 Sep 2025 15:45:02 +0200 Subject: [PATCH 14/22] Typo in var name Signed-off-by: Martin Zeithaml --- test/config-syntax.sh | 2 +- test/environments.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/config-syntax.sh b/test/config-syntax.sh index 4746d32..d7e278c 100755 --- a/test/config-syntax.sh +++ b/test/config-syntax.sh @@ -19,7 +19,7 @@ if [ ! -z "${1}" ]; then fi LAUNCHER='../bin/zowe_launcher' -if [ ! -f "{LAUNCHER}" ]; then +if [ ! -f "${LAUNCHER}" ]; then echo "Executable \"${LAUNCHER}\" not found." exit 1 fi diff --git a/test/environments.sh b/test/environments.sh index 94bd27c..b889440 100755 --- a/test/environments.sh +++ b/test/environments.sh @@ -19,7 +19,7 @@ if [ ! -z "${1}" ]; then fi LAUNCHER='../bin/zowe_launcher' -if [ ! -f "{LAUNCHER}" ]; then +if [ ! -f "${LAUNCHER}" ]; then echo "Executable \"${LAUNCHER}\" not found." exit 1 fi From fb5ae68d96548db6d266a93bc70c77d10c3db270 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Mon, 29 Sep 2025 11:16:04 +0200 Subject: [PATCH 15/22] Unix variable names bug Signed-off-by: Martin Zeithaml --- src/main.c | 16 ++++++++++++---- test/environments.sh | 31 +++++++++++++++++++++++++++---- test/files/zowe.environments.yaml | 28 ++++++++++++++++++++-------- 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/main.c b/src/main.c index 6a78be1..5aba603 100644 --- a/src/main.c +++ b/src/main.c @@ -480,11 +480,19 @@ static char* jsonToString(Json *json) { } } -static bool is_valid_key(char *key) { +// Zowe.environments key must follow Unix variable name syntax: +// alphaNum | underscore & first char is not a digit +static bool is_key_valid_unix_name(char *key) { int length = strlen(key); + if (!length) { + return false; + } + if (isdigit(key[0])) { + return false; + } for (int i = 0; i < length; i++) { if (isalnum(key[i])) continue; - if (strchr("_-", key[i])) continue; + if (key[i] == '_') continue; return false; } return true; @@ -540,8 +548,8 @@ static void set_shared_uss_env(ConfigManager *configmgr) { // Get all environment variables defined in zowe.yaml and put them in the output as they are for (JsonProperty *property = jsonObjectGetFirstProperty(object); property != NULL; property = jsonObjectGetNextProperty(property)) { char *key = jsonPropertyGetKey(property); - if (!is_valid_key(key)) { - WARN("Key in zowe.yaml `zowe.environments.%s` is invalid and it will be ignored\n", key); + if (!is_key_valid_unix_name(key)) { + WARN("Key in configuration `zowe.environments.%s` is invalid and it will be ignored\n", key); continue; } diff --git a/test/environments.sh b/test/environments.sh index b889440..5fe11ac 100755 --- a/test/environments.sh +++ b/test/environments.sh @@ -13,6 +13,7 @@ # --------------------------------------------------- print= +errors=0 if [ ! -z "${1}" ]; then print='1' @@ -27,17 +28,39 @@ fi ZOWE_YAML="./files/zowe.environments.yaml" LAUNCHER_OUTPUT= +LAUNCHER_OUTPUT_TEST_VAR= +LAUNCHER_OUTPUT_KEYS= export ZLDEBUG='ON' export CONFIG="FILE(${ZOWE_YAML})" +LAUNCHER_OUTPUT=$("${LAUNCHER}" "ha1" 2>&1) + if [ ! -z "${print}" ]; then - "${LAUNCHER}" "ha1" + printf "%s" "${LAUNCHER_OUTPUT}" fi # awk prints between TEST_VAR_START= and TEST_VAR_END= -LAUNCHER_OUTPUT=$("${LAUNCHER}" "ha1" 2>&1 | awk '/TEST_VAR_START=/{flag=1}/TEST_VAR_END=/{print; flag=0}flag') -printf "%s\n\n" "${LAUNCHER_OUTPUT}" +LAUNCHER_OUTPUT_TEST_VAR=$(printf "%s" "${LAUNCHER_OUTPUT}" | awk '/TEST_VAR_START=/{flag=1}/TEST_VAR_END=/{print; flag=0}flag') +printf "%s\n\n" "${LAUNCHER_OUTPUT_TEST_VAR}" awk '/TEST_VAR_START/{flag=1}/TEST_VAR_END/{print; flag=0}flag' "${ZOWE_YAML}" -exit 0 +printf "\n---zowe.environments.* expected to be ignored ---\n\n" + +LAUNCHER_OUTPUT_KEYS=$(printf "%s" "${LAUNCHER_OUTPUT}" | grep -e 'Key in configuration') + +while read -r line; do + if [ -n "$(echo "${line}" | grep -e '')" ]; then + key="$(echo "${line}" | awk -F: '{ print $1}')" + key="\`zowe.environments.${key}\`" + matchKey="$(printf "%s" "${LAUNCHER_OUTPUT_KEYS}" | grep -e "${key}")" + if [ -n "${matchKey}" ]; then + printf "Key '%s' found:\n %s\n" "${key}" "${matchKey}" + else + echo "Key '${key}' not found!" + errors=`expr $errors + 1` + fi + fi +done < "${ZOWE_YAML}" + +exit $errors diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml index 4b657c3..c1c0163 100644 --- a/test/files/zowe.environments.yaml +++ b/test/files/zowe.environments.yaml @@ -46,11 +46,23 @@ zowe: - orange TEST_VAR_ARRAY_02: ['A', 'B', 'C'] # Array TEST_VAR_END: \E\N\D # "\\E\\N\\D" - runtimeDirectory: "${{ () => { - let thisPath = os.realpath('./fakeRuntime'); - if (thisPath[1] == 0) { - return thisPath[0]; - } - return undefined; - } () - }}" + # *** Ignored keys *** + -key-: ~ # + ?key: '?' # + 1+1: =2 # + 1-1: "=0" # + _!_: '!!!' # + 1TEST: true # + 3_141592: 6535 # + (): !!int 0 # + ~null: not null # + =: equal sign # +

: heading # +runtimeDirectory: "${{ () => { + let thisPath = os.realpath('./fakeRuntime'); + if (thisPath[1] == 0) { + return thisPath[0]; + } + return undefined; + } () + }}" From fd9d3861c235057e1bab399ded865efdd77fd5de Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Mon, 29 Sep 2025 11:24:17 +0200 Subject: [PATCH 16/22] zowe.runtimeDirectory indentation Signed-off-by: Martin Zeithaml --- test/files/zowe.environments.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml index c1c0163..e4a1a7c 100644 --- a/test/files/zowe.environments.yaml +++ b/test/files/zowe.environments.yaml @@ -58,7 +58,7 @@ zowe: ~null: not null # =: equal sign #

: heading # -runtimeDirectory: "${{ () => { + runtimeDirectory: "${{ () => { let thisPath = os.realpath('./fakeRuntime'); if (thisPath[1] == 0) { return thisPath[0]; From 06fd44b3d5f827205cb57d11ee1de5f58b48694d Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Mon, 29 Sep 2025 11:35:15 +0200 Subject: [PATCH 17/22] Readme update Signed-off-by: Martin Zeithaml --- test/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/README.md b/test/README.md index 9986bab..468d47e 100644 --- a/test/README.md +++ b/test/README.md @@ -17,4 +17,8 @@ Return code is the number detected errors. To see an output, use any parameter, ## Environments -Script for testing `zowe.environments`, especially escaping strings with `\` or `"`. See [config](./files/zowe.environments.yaml) used for testing. It will only print filtered output of Launcher and configuration. +Script for testing `zowe.environments`: +* Escaping strings with `\` or `"`. It will only print filtered output of Launcher and configuration. +* Ignoring environment variables, which are not valid unix names. + +See [config](./files/zowe.environments.yaml) used for testing. From ebb77c24d2343694e315511fafb781de8a0e830f Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Mon, 29 Sep 2025 11:38:15 +0200 Subject: [PATCH 18/22] Add rc to comment Signed-off-by: Martin Zeithaml --- test/environments.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/environments.sh b/test/environments.sh index 5fe11ac..3b82e20 100755 --- a/test/environments.sh +++ b/test/environments.sh @@ -8,9 +8,8 @@ # # Copyright Contributors to the Zowe Project. -# --------------------------------------------------- # Start with any parameter -> prints Launcher's output -# --------------------------------------------------- +# rc of this = number of errors found for "WARN Key in configuration `zowe.environments.` is invalid" print= errors=0 From f08dd70766f4a77da94533fceb325d83ff94d484 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Mon, 29 Sep 2025 15:11:35 +0200 Subject: [PATCH 19/22] Test updated Signed-off-by: Martin Zeithaml --- test/README.md | 3 ++- test/environments.sh | 25 ++++++++++++++++++------- test/files/zowe.environments.yaml | 13 ++++++++----- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/test/README.md b/test/README.md index 468d47e..04a4715 100644 --- a/test/README.md +++ b/test/README.md @@ -18,7 +18,8 @@ Return code is the number detected errors. To see an output, use any parameter, ## Environments Script for testing `zowe.environments`: -* Escaping strings with `\` or `"`. It will only print filtered output of Launcher and configuration. +* Escaping strings with `\` or `"`. It checks only if the variable is in output. * Ignoring environment variables, which are not valid unix names. +* Return code is the number detected errors. See [config](./files/zowe.environments.yaml) used for testing. diff --git a/test/environments.sh b/test/environments.sh index 3b82e20..05869ca 100755 --- a/test/environments.sh +++ b/test/environments.sh @@ -9,7 +9,7 @@ # Copyright Contributors to the Zowe Project. # Start with any parameter -> prints Launcher's output -# rc of this = number of errors found for "WARN Key in configuration `zowe.environments.` is invalid" +# rc of this = number of errors found print= errors=0 @@ -38,23 +38,34 @@ if [ ! -z "${print}" ]; then printf "%s" "${LAUNCHER_OUTPUT}" fi +printf "\n---zowe.environments.TEST_VAR_* expected to be used or ignored ---\n\n" # awk prints between TEST_VAR_START= and TEST_VAR_END= LAUNCHER_OUTPUT_TEST_VAR=$(printf "%s" "${LAUNCHER_OUTPUT}" | awk '/TEST_VAR_START=/{flag=1}/TEST_VAR_END=/{print; flag=0}flag') -printf "%s\n\n" "${LAUNCHER_OUTPUT_TEST_VAR}" - -awk '/TEST_VAR_START/{flag=1}/TEST_VAR_END/{print; flag=0}flag' "${ZOWE_YAML}" +while read -r line; do + if [ -n "$(echo "${line}" | grep 'TEST_VAR_')" ]; then + key=$(echo "${line}" | cut -d: -f1) + if [ -n "$(echo "${line}" | grep '#')" ]; then + output=$(echo "${LAUNCHER_OUTPUT_TEST_VAR}" | grep "${key}") + if [ -n "${output}" ]; then + printf "OK: %s\n" "${output}" + else + echo "Key '${key}' not found!" + errors=`expr $errors + 1` + fi + + fi + fi +done < "${ZOWE_YAML}" printf "\n---zowe.environments.* expected to be ignored ---\n\n" - LAUNCHER_OUTPUT_KEYS=$(printf "%s" "${LAUNCHER_OUTPUT}" | grep -e 'Key in configuration') - while read -r line; do if [ -n "$(echo "${line}" | grep -e '')" ]; then key="$(echo "${line}" | awk -F: '{ print $1}')" key="\`zowe.environments.${key}\`" matchKey="$(printf "%s" "${LAUNCHER_OUTPUT_KEYS}" | grep -e "${key}")" if [ -n "${matchKey}" ]; then - printf "Key '%s' found:\n %s\n" "${key}" "${matchKey}" + printf "OK: Key '%s' found: %s\n" "${key}" "${matchKey}" else echo "Key '${key}' not found!" errors=`expr $errors + 1` diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml index e4a1a7c..b3792de 100644 --- a/test/files/zowe.environments.yaml +++ b/test/files/zowe.environments.yaml @@ -36,15 +36,18 @@ zowe: Under thy own life's key: be check'd for silence, But never tax'd for speech. # *** Null *** - TEST_VAR_NULL_01: # - TEST_VAR_NULL_02: ~ # - TEST_VAR_NULL_03: null # + TEST_VAR_NULL_01: + TEST_VAR_NULL_02: ~ + TEST_VAR_NULL_03: null # *** Array *** - TEST_VAR_ARRAY_01: # Array + TEST_VAR_ARRAY_01: - kiwi - banana - orange - TEST_VAR_ARRAY_02: ['A', 'B', 'C'] # Array + TEST_VAR_ARRAY_02: ['A', 'B', 'C'] + TEST_VAR_NESTED: + enabled: true + disabled: false TEST_VAR_END: \E\N\D # "\\E\\N\\D" # *** Ignored keys *** -key-: ~ # From 8116dc2255d13a17827e56ef90200cb534f9f87c Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Tue, 30 Sep 2025 11:35:52 +0200 Subject: [PATCH 20/22] ESJ test cases Signed-off-by: Martin Zeithaml --- test/files/zowe.environments.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/files/zowe.environments.yaml b/test/files/zowe.environments.yaml index b3792de..66b96fd 100644 --- a/test/files/zowe.environments.yaml +++ b/test/files/zowe.environments.yaml @@ -48,6 +48,17 @@ zowe: TEST_VAR_NESTED: enabled: true disabled: false + # *** Embedded JS *** + TEST_VAR_EJS_01: "${{ zowe.environments.TEST_VAR_INT_01 }}" # zowe.environments.TEST_VAR_INT_01 + TEST_VAR_EJS_02: "${{ 1+1*7 }}" # 8 + TEST_VAR_EJS_03: "${{ 'EJS' }}" # "EJS" + TEST_VAR_EJS_04: "${{ `EJS` }}" # "EJS" + TEST_VAR_EJS_05: "${{ \"EJS\" }}" # "EJS" + TEST_VAR_EJS_06: "${{ `E` + 'J' + \"S\" }}" # "EJS" + TEST_VAR_EJS_07: "${{ `\\` }}" # "\\" + TEST_VAR_EJS_08: "${{ /* # true */ + () => { if (1 == 1) return true } (); + }}" TEST_VAR_END: \E\N\D # "\\E\\N\\D" # *** Ignored keys *** -key-: ~ # From d1f10ee3e48dbeddf8a49bf38788906abea30318 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 2 Oct 2025 08:37:33 +0200 Subject: [PATCH 21/22] Update based on code review Signed-off-by: Martin Zeithaml --- src/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 5aba603..0e91a8d 100644 --- a/src/main.c +++ b/src/main.c @@ -481,8 +481,9 @@ static char* jsonToString(Json *json) { } // Zowe.environments key must follow Unix variable name syntax: -// alphaNum | underscore & first char is not a digit -static bool is_key_valid_unix_name(char *key) { +// * The first char must not be a digit +// * Any characters must be either alphanumeric or an underscore +static bool is_key_valid_unix_name(const char *key) { int length = strlen(key); if (!length) { return false; From b12ce679cfb332ce1c434e3087fa0f50218ca9ae Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 19 Mar 2026 09:04:25 +0100 Subject: [PATCH 22/22] Sync with staging Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 5 ++++- test/config-syntax.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3019c48..d114279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,12 @@ All notable changes to the Zowe Launcher package will be documented in this file. This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section. -## 3.4.0 +## 3.5.0 - Bugfix: Escape backslash when used in environment variable ([#168](https://github.com/zowe/launcher/pull/168)) +## 3.4.0 +- Enhancement: Message `ZWEL0021I` includes the version of launcher ([#167](https://github.com/zowe/launcher/pull/167)) + ## 3.3.0 - Bugfix: `zowe.sysMessages` feature was ignoring messages where the matching string was after the position of 126 ([#157](https://github.com/zowe/launcher/pull/157)) - Enhancement: Launcher can now accept PARMLIB CONFIG entries that have more than one member name ([#146](https://github.com/zowe/launcher/pull/146)) diff --git a/test/config-syntax.sh b/test/config-syntax.sh index d7e278c..419ce5c 100755 --- a/test/config-syntax.sh +++ b/test/config-syntax.sh @@ -21,7 +21,7 @@ fi LAUNCHER='../bin/zowe_launcher' if [ ! -f "${LAUNCHER}" ]; then echo "Executable \"${LAUNCHER}\" not found." - exit 1 + exit 255 fi ABS_PATH=$(cd .; pwd)