From 2eba2817aa08247dce3cf1e71e48238dff71e9a9 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sun, 28 Apr 2024 12:19:49 +0100 Subject: [PATCH] OpamEnv.split_var: use correct split functions The cases of this match were the wrong way around. Note that this regresses #4861's quoted directory test. --- master_changes.md | 2 +- src/state/opamEnv.ml | 4 ++-- tests/reftests/env.test | 20 ++++++++++---------- tests/reftests/env.win32.test | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/master_changes.md b/master_changes.md index dfc131ae66b..09e8ba58dd6 100644 --- a/master_changes.md +++ b/master_changes.md @@ -57,6 +57,7 @@ users) ## Env * [BUG] Fix reverting of environment variables, principally on Windows [#5935 @dra27 fix #5838] + * [BUG] Fix splitting environment variables [#5935 @dra27] ## Opamfile @@ -65,7 +66,6 @@ users) ## Format upgrade ## Sandbox - ## VCS ## Build diff --git a/src/state/opamEnv.ml b/src/state/opamEnv.ml index 947b2657cc1..c44a1c4b5a2 100644 --- a/src/state/opamEnv.ml +++ b/src/state/opamEnv.ml @@ -150,9 +150,9 @@ let split_var ~(sepfmt:sep_path_format) var value = in let sep = OpamTypesBase.char_of_separator separator in match format with - | Target_quoted | Host_quoted -> - OpamStd.String.split value sep | Target | Host -> + OpamStd.String.split value sep + | Target_quoted | Host_quoted -> (* we suppose that it is in the form: - "quoted":unquoted - unquoted:"quoted" diff --git a/tests/reftests/env.test b/tests/reftests/env.test index 4e2b3317c1d..8f6fcc96ee8 100644 --- a/tests/reftests/env.test +++ b/tests/reftests/env.test @@ -212,8 +212,8 @@ NV_VARS_5926_M_1=b:a1:a2 NV_VARS_5926_M_2=a1:a2:b NV_VARS_5926_M_3=b:a1:a2 NV_VARS_5926_M_4=a1:a2:b -NV_VARS_5926_S_1=a: -NV_VARS_5926_S_2=:a +NV_VARS_5926_S_1=a +NV_VARS_5926_S_2=a NV_VARS_5926_S_3=a: NV_VARS_5926_S_4=:a NV_VARS_5926_T_1=b:a: @@ -247,8 +247,8 @@ NV_VARS_5926_M_1='b:a1:a2': export NV_VARS_5926_M_1: NV_VARS_5926_M_2='a1:a2:b': export NV_VARS_5926_M_2: NV_VARS_5926_M_3='b:a1:a2': export NV_VARS_5926_M_3: NV_VARS_5926_M_4='a1:a2:b': export NV_VARS_5926_M_4: -NV_VARS_5926_S_1='a:': export NV_VARS_5926_S_1: -NV_VARS_5926_S_2=':a': export NV_VARS_5926_S_2: +NV_VARS_5926_S_1='a': export NV_VARS_5926_S_1: +NV_VARS_5926_S_2='a': export NV_VARS_5926_S_2: NV_VARS_5926_S_3='a:': export NV_VARS_5926_S_3: NV_VARS_5926_S_4=':a': export NV_VARS_5926_S_4: NV_VARS_5926_T_1='b:a:': export NV_VARS_5926_T_1: @@ -323,8 +323,8 @@ NV_VARS_5926_M_1=b:a1:a2 NV_VARS_5926_M_2=a1:a2:b NV_VARS_5926_M_3=b:a1:a2 NV_VARS_5926_M_4=a1:a2:b -NV_VARS_5926_S_1=a: -NV_VARS_5926_S_2=:a +NV_VARS_5926_S_1=a +NV_VARS_5926_S_2=a NV_VARS_5926_S_3=a: NV_VARS_5926_S_4=:a NV_VARS_5926_T_1=b:a: @@ -358,8 +358,8 @@ NV_VARS_5926_M_1='b:a1:a2': export NV_VARS_5926_M_1: NV_VARS_5926_M_2='a1:a2:b': export NV_VARS_5926_M_2: NV_VARS_5926_M_3='b:a1:a2': export NV_VARS_5926_M_3: NV_VARS_5926_M_4='a1:a2:b': export NV_VARS_5926_M_4: -NV_VARS_5926_S_1='a:': export NV_VARS_5926_S_1: -NV_VARS_5926_S_2=':a': export NV_VARS_5926_S_2: +NV_VARS_5926_S_1='a': export NV_VARS_5926_S_1: +NV_VARS_5926_S_2='a': export NV_VARS_5926_S_2: NV_VARS_5926_S_3='a:': export NV_VARS_5926_S_3: NV_VARS_5926_S_4=':a': export NV_VARS_5926_S_4: NV_VARS_5926_T_1='b:a:': export NV_VARS_5926_T_1: @@ -480,8 +480,8 @@ NV_VARS_5926_M_1='b:a1:a2': export NV_VARS_5926_M_1: NV_VARS_5926_M_2='a1:a2:b': export NV_VARS_5926_M_2: NV_VARS_5926_M_3='b:a1:a2': export NV_VARS_5926_M_3: NV_VARS_5926_M_4='a1:a2:b': export NV_VARS_5926_M_4: -NV_VARS_5926_S_1='a:': export NV_VARS_5926_S_1: -NV_VARS_5926_S_2=':a': export NV_VARS_5926_S_2: +NV_VARS_5926_S_1='a': export NV_VARS_5926_S_1: +NV_VARS_5926_S_2='a': export NV_VARS_5926_S_2: NV_VARS_5926_S_3='a:': export NV_VARS_5926_S_3: NV_VARS_5926_S_4=':a': export NV_VARS_5926_S_4: NV_VARS_5926_T_1='b:a:': export NV_VARS_5926_T_1: diff --git a/tests/reftests/env.win32.test b/tests/reftests/env.win32.test index 55d631c4da3..76e3571377f 100644 --- a/tests/reftests/env.win32.test +++ b/tests/reftests/env.win32.test @@ -26,6 +26,7 @@ Done. set "MANPATH=:"${BASEDIR}/OPAM/rewriting/man"" set PATH=${BASEDIR}/OPAM/rewriting/bin;C:\Devel\bin1;C:\Devel\bin2;"C:\Devel\bin3;";C:\Devel\bin4;ZZZ:\; ### opam exec -- opam env --shell=cmd --revert | grep 'ZZZ:' | 'ZZZ:\\.*' -> 'ZZZ:\' | 'set "P' -> 'set P' +set PATH=C:\Devel\bin1;C:\Devel\bin2;"C:\Devel\bin3;";C:\Devel\bin4;ZZZ:\ ### : Test for #5838 ### opam env | grep MANPATH MANPATH=':"${BASEDIR}/OPAM/rewriting/man"'; export MANPATH;