From e6953f0891efe932dd16f54b52288a015b974536 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 18:15:54 -0400 Subject: [PATCH] Resolve windows opensearch-env.bat having variable delayed expansion issues on OPENSEARCH_HOME assignment introduced in #6956 (#7080) (#7111) * Resolve windows opensearch-env.bat having variable delayed expansion issues on OPENSEARCH_HOME assignment * Remove changelog entry --------- (cherry picked from commit 810b98555ea612cbae8310bf670cd515eb8cab34) Signed-off-by: Peter Zhu Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- distribution/src/bin/opensearch-env.bat | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/distribution/src/bin/opensearch-env.bat b/distribution/src/bin/opensearch-env.bat index 4b5d2237e7d0e..be9f0411e39f8 100644 --- a/distribution/src/bin/opensearch-env.bat +++ b/distribution/src/bin/opensearch-env.bat @@ -3,18 +3,21 @@ set SCRIPT=%0 rem determine OpenSearch home; to do this, we strip from the path until we rem find bin, and then strip bin (there is an assumption here that there is no rem nested directory under bin also named bin) -if not defined OPENSEARCH_HOME ( - for %%I in (%SCRIPT%) do set OPENSEARCH_HOME=%%~dpI - - :opensearch_home_loop - for %%I in ("%OPENSEARCH_HOME:~1,-1%") do set DIRNAME=%%~nxI - if not "%DIRNAME%" == "bin" ( - for %%I in ("%OPENSEARCH_HOME%..") do set OPENSEARCH_HOME=%%~dpfI - goto opensearch_home_loop - ) +if not defined OPENSEARCH_HOME goto opensearch_home_start_setup +goto opensearch_home_done_setup + +:opensearch_home_start_setup +for %%I in (%SCRIPT%) do set OPENSEARCH_HOME=%%~dpI + +:opensearch_home_loop +for %%I in ("%OPENSEARCH_HOME:~1,-1%") do set DIRNAME=%%~nxI +if not "%DIRNAME%" == "bin" ( for %%I in ("%OPENSEARCH_HOME%..") do set OPENSEARCH_HOME=%%~dpfI + goto opensearch_home_loop ) +for %%I in ("%OPENSEARCH_HOME%..") do set OPENSEARCH_HOME=%%~dpfI +:opensearch_home_done_setup rem now set the classpath set OPENSEARCH_CLASSPATH=!OPENSEARCH_HOME!\lib\*