diff --git a/master_changes.md b/master_changes.md index 57df5be7680..34b7da757b3 100644 --- a/master_changes.md +++ b/master_changes.md @@ -64,6 +64,12 @@ users) ## Clean ## Env + * [BUG] Fix reverting of environment variables, principally on Windows [#5935 @dra27 fix #5838] + * [BUG] Fix splitting environment variables [#5935 @dra27] + * [BUG] When opam creates an empty variable then appends/prepends a value, ensure no additional separator is added [#5935 @dra27 - fix #5925] + * [BUG] Fix `x-env-path-rewrite` splitting of values when reverting [#5935 @dra27 - fix #5838] + * [BUG] Rework the logic of := and =: so that an empty entry is correctly preserved on multiple updates [#5935 @dra27 - fix #5926] + * [BUG] Fix incorrect reverting of `=+` and `=:` [#5935 @dra27 - fix #5926] ## Opamfile @@ -77,7 +83,6 @@ users) * Reset the "jobs" config variable when upgrading from opam 2.1 to 2.2, instead of 2.0 to 2.1 [#5904 @kit-ty-kate - fix #5816] ## Sandbox - ## VCS ## Build @@ -118,8 +123,15 @@ users) * tree: add a test for packages that have variables in their transitive dependencies [#5919 @rjbou] * tree: add test for `opam tree pkg --with-test --no-switch` [#5919 @rjbou] * Update opam root version test with root version bump [#5904 @rjbou] + * env tests: use `sort` to increase stability of the `opam env` output [#5935 @dra27 @rjbou] + * env.win32: add mixed slashes test [#5935 @dra27] + * env.win32: add test for environment revert not working correctly for Unix-like variables on Windows [#5935 @dra27] + * env.win32: add regression test for reverting additions to PATH-like variables [#5935 @dra27] + * env tests: add regression test for append/prepend operators to empty environment variables [#5925, #5935 @dra27] + * env.win32: add regression test for handling the empty entry in PATH-like variables [#5926, #5935 @dra27] ### Engine + * Add `sort` command [#5935 @dra27] ## Github Actions @@ -140,3 +152,4 @@ users) ## opam-format ## opam-core + * `OpamStd.String`: add `split_quoted` that preserves quoted separator [#5935 @dra27] diff --git a/src/core/opamStd.ml b/src/core/opamStd.ml index a691c2aa986..d0b50d028ba 100644 --- a/src/core/opamStd.ml +++ b/src/core/opamStd.ml @@ -710,6 +710,26 @@ module OpamString = struct |_ -> [] in List.rev (aux acc0 tokens) + let split_quoted path sep = + let length = String.length path in + let rec f acc index current last normal = + if (index : int) = length then + let current = current ^ String.sub path last (index - last) in + List.rev (if current <> "" then current::acc else acc) + else + let c = path.[index] + and next = succ index in + if (c : char) = sep && normal || c = '"' then + let current = current ^ String.sub path last (index - last) in + if c = '"' then + f acc next current next (not normal) + else + let acc = if current = "" then acc else current::acc in + f acc next "" next true + else + f acc next current last normal in + f [] 0 "" 0 true + let fold_left f acc s = let acc = ref acc in for i = 0 to String.length s - 1 do acc := f !acc s.[i] done; @@ -877,24 +897,8 @@ module OpamSys = struct let path_sep = if Sys.win32 then ';' else ':' let split_path_variable ?(clean=true) = - if Sys.win32 then fun path -> - let length = String.length path in - let rec f acc index current last normal = - if index = length then - let current = current ^ String.sub path last (index - last) in - List.rev (if current <> "" then current::acc else acc) - else let c = path.[index] - and next = succ index in - if c = ';' && normal || c = '"' then - let current = current ^ String.sub path last (index - last) in - if c = '"' then - f acc next current next (not normal) - else - let acc = if current = "" then acc else current::acc in - f acc next "" next true - else - f acc next current last normal in - f [] 0 "" 0 true + if Sys.win32 then + fun path -> OpamString.split_quoted path ';' else fun path -> let split = if clean then OpamString.split else OpamString.split_delim in split path path_sep diff --git a/src/core/opamStd.mli b/src/core/opamStd.mli index 903f11ce10c..ce2a4aee712 100644 --- a/src/core/opamStd.mli +++ b/src/core/opamStd.mli @@ -314,6 +314,12 @@ module String : sig contiguous delimiters) *) val split_delim: string -> char -> string list + (** Splits a variable at the given character, but allowing double-quote + characters to protect the delimiter. + + [split_quoted "foo\";\"bar;baz" ';' = ["foo;bar"; "baz"]] *) + val split_quoted: string -> char -> string list + val fold_left: ('a -> char -> 'a) -> 'a -> string -> 'a val is_hex: string -> bool diff --git a/src/state/opamEnv.ml b/src/state/opamEnv.ml index 8c783f1b5cf..6922c9df87a 100644 --- a/src/state/opamEnv.ml +++ b/src/state/opamEnv.ml @@ -45,9 +45,20 @@ type sep_path_format = [ | `rewrite of separator * path_format (* path, rewrite using sep & fmt *) ] -let transform_format ~(sepfmt:sep_path_format) = +type transform = { + tr_entry: string; (* Entry (directory) in native, normalised form *) + tr_raw: string; (* Actual string to put into the final variable *) + tr_sep: char; (* Separator to use if (and only if) any entries follow *) +} + +let transform_format ~(sepfmt:sep_path_format) var = match sepfmt with - | `norewrite -> fun x -> x + | `norewrite -> + fun arg -> + { tr_entry = arg; + tr_raw = arg; + tr_sep = OpamTypesBase.char_of_separator (fst (default_sep_fmt var)); + } | (`rewrite_default _ | `rewrite _) as sepfmt -> let separator, format = match sepfmt with @@ -64,14 +75,26 @@ let transform_format ~(sepfmt:sep_path_format) = (* noop on non windows *) (Lazy.force OpamSystem.get_cygpath_path_transform) ~pathlist:false in + let separator = OpamTypesBase.char_of_separator separator in match format with - | Target | Host -> translate + | Target | Host -> + fun arg -> + let path = translate arg in + { tr_entry = path; + tr_raw = path; + tr_sep = separator; + } | Target_quoted | Host_quoted -> fun arg -> let path = translate arg in - let separator = OpamTypesBase.char_of_separator separator in - if String.contains path separator then - "\""^path^"\"" else path + let quoted_path = + if String.contains path separator then + "\""^path^"\"" else path + in + { tr_entry = path; + tr_raw = quoted_path; + tr_sep = separator; + } let resolve_separator_and_format : type r. (r, 'a) env_update -> (spf_resolved, 'a) env_update = @@ -134,14 +157,43 @@ let resolve_separator_and_format : in { upd with envu_rewrite } +let split_path_variable path sep = + let length = String.length path in + let rec f acc index current current_raw last normal = + if (index : int) = length then + let final = String.sub path last (index - last) in + let current = current ^ final in + let current_raw = current_raw ^ final in + let elem = {tr_entry = current; tr_raw = current_raw; tr_sep = sep } in + List.rev (elem::acc) + else + let c = path.[index] + and next = succ index in + if c = sep && normal || c = '"' then + let segment = String.sub path last (index - last) in + let current = current ^ segment in + let current_raw = current_raw ^ segment in + let elem = {tr_entry = current; tr_raw = current_raw; tr_sep = sep } in + if c = '"' then + f acc next current (current_raw ^ "\"") next (not normal) + else if (next : int) = length then (* path ends with a separator *) + let empty = { tr_entry = ""; tr_raw = ""; tr_sep = sep } in + List.rev (empty::elem::acc) + else (* c = sep; text follows *) + f (elem::acc) next "" "" next true + else + f acc next current current_raw last normal + in + f [] 0 "" "" 0 true + (* - Environment and updates handling - *) let split_var ~(sepfmt:sep_path_format) var value = match sepfmt with | `norewrite -> - default_sep_fmt var - |> fst - |> char_of_separator - |> OpamStd.String.split value + let sep = char_of_separator (fst (default_sep_fmt var)) in + List.map (fun s -> + { tr_entry = s; tr_raw = s; tr_sep = sep}) + (OpamStd.String.split_delim value sep) | (`rewrite_default _ | `rewrite _) as sepfmt -> let separator, format = match sepfmt with @@ -149,52 +201,47 @@ let split_var ~(sepfmt:sep_path_format) var value = | `rewrite (sep, fmt) -> sep, fmt in let sep = OpamTypesBase.char_of_separator separator in + if (value : string) = String.make 1 sep then + [{ tr_entry = ""; tr_raw = value; tr_sep = sep }] + else match format with - | Target_quoted | Host_quoted -> - OpamStd.String.split value sep | Target | Host -> - (* we suppose that it is in the form: - - "quoted":unquoted - - unquoted:"quoted" - - "quoted":unquoted:"quoted" - - unquoted:"quoted":unquoted - - "quoted" - - unquoted - *) - let rec aux remaining acc = - match String.get remaining 0 with - | '"' -> - (let remaining = - String.sub remaining 1 (String.length remaining - 1) - in - match OpamStd.String.cut_at remaining '"' with - | Some (quoted, rest) -> - aux rest (("\""^quoted^"\"")::acc) - | None -> remaining::acc) - | _ -> - let remaining = - if Char.equal (String.get remaining 0) sep then - String.sub remaining 1 (String.length remaining - 1) - else remaining in - (match OpamStd.String.cut_at remaining sep with - | Some (unquoted, rest) -> - aux rest (unquoted::acc) - | None -> remaining::acc) - | exception Invalid_argument _ -> acc - in - List.rev @@ aux value [] - -let join_var ~(sepfmt:sep_path_format) var values = - let separator = + List.map (fun s -> + { tr_entry = s; tr_raw = s; tr_sep = sep}) + (OpamStd.String.split_delim value sep) + | Target_quoted | Host_quoted -> + split_path_variable value sep + +(* Auxiliaries for join_var - cf. String.concat *) +let rec sum_lengths acc = function + | [{ tr_raw = raw; _}] -> acc + String.length raw + | { tr_raw = raw; _}::tl -> sum_lengths (acc + String.length raw + 1) tl + | [] -> acc (* semantically unreachable *) + +let rec unsafe_blits dst pos = function + | [] -> + Bytes.unsafe_to_string dst + | [{ tr_raw = raw; _}] -> + String.unsafe_blit raw 0 dst pos (String.length raw); + Bytes.unsafe_to_string dst + | { tr_raw = raw; tr_sep = sep; _}::tl -> + let length = String.length raw in + String.unsafe_blit raw 0 dst pos length; + Bytes.unsafe_set dst (pos + length) sep; + unsafe_blits dst (pos + length + 1) tl + +let join_var values = + if values = [] then "" else + unsafe_blits (Bytes.create (sum_lengths 0 values)) 0 values + +let separator_char_for ~sepfmt var = + let (separator, _) = match sepfmt with - | `norewrite -> fst (default_sep_fmt var) - | `rewrite_default var -> fst (default_sep_fmt_str var) - | `rewrite (sep, _) -> sep + | `norewrite -> default_sep_fmt var + | `rewrite_default var -> default_sep_fmt_str var + | `rewrite spf -> spf in - String.concat - (String.make 1 (OpamTypesBase.char_of_separator separator)) - values - + OpamTypesBase.char_of_separator separator (* To allow in-place updates, we store intermediate values of path-like as a pair of list [(rl1, l2)] such that the value is [List.rev_append rl1 l2] and @@ -205,73 +252,133 @@ let unzip_to ~sepfmt var elt current = (* If [r = l @ rs] then [remove_prefix l r] is [Some rs], otherwise [None] *) let rec remove_prefix l r = match l, r with - | (l::ls, r::rs) when l = r -> + | {tr_entry = l; _}::ls, { tr_entry = r; _}::rs when l = r -> remove_prefix ls rs | ([], rs) -> Some rs | _ -> None in - match (if String.equal elt "" then [""] - else split_var ~sepfmt var elt) with + (* Split elt if necessary *) + let elts = + if String.equal elt "" then + [{ tr_entry = ""; tr_raw = ""; + tr_sep = separator_char_for ~sepfmt var }] + else + match sepfmt with + | `norewrite -> + (* Given FOO += "", then even with + `norewrite it is necessary to split the value as FOO itself + will have been split - i.e. if we don't split elt here then + it cannot be reverted if it contains multiple directories + (which would regression #4861) *) + let sepfmt = `rewrite_default (var :> string) in + split_var ~sepfmt var elt + | `rewrite_default _ -> + (* If no rewrite has been specified at all, then split elt as, + again, #4861 would be regressed otherwise. *) + split_var ~sepfmt var elt + | `rewrite _ -> + (* If a rewrite rule _is_ in effect, then opam 2.2's limited + (but compatible) semantics for setenv and build-env mean that + we're _assuming_ that elt only contains a single path. This + should be addressed in opam 3.0 by having a somewhat richer + syntax for environment changes to make clear the "type" of + the value in FOO += "bar". *) + [{ tr_entry = elt; tr_raw = elt; + tr_sep = separator_char_for ~sepfmt var }] + in + match elts with | [] -> invalid_arg "OpamEnv.unzip_to" - | hd::tl -> + | { tr_entry = hd; _}::tl -> let rec aux acc = function | [] -> None - | x::r -> + | ({ tr_entry = x; _} as v)::r -> if String.equal x hd then match remove_prefix tl r with | Some r -> Some (acc, r) - | None -> aux (x::acc) r - else aux (x::acc) r + | None -> aux (v::acc) r + else aux (v::acc) r in aux [] current let rezip ?insert (l1, l2) = List.rev_append l1 (match insert with None -> l2 | Some i -> i::l2) -let rezip_to_string ~sepfmt var ?insert z = - join_var ~sepfmt var (rezip ?insert z) +let rezip_to_string ?insert z = + join_var (rezip ?insert z) - -(* apply_zip take an already transformed arg *) -let apply_op_zip ~sepfmt op arg (rl1,l2 as zip) = - let arg = transform_format ~sepfmt arg in - let colon_eq ?(eqcol=false) = function (* prepend a, but keep ":"s *) - | [] | [""] -> [], [arg; ""] - | "" :: l -> - (* keep surrounding colons *) - if eqcol then l@[""], [arg] else l, [""; arg] - | l -> l, [arg] - in +let apply_op_zip ~sepfmt var op arg (rl1,l2 as zip) = + let arg = transform_format ~sepfmt var arg in + let empty_tr = { tr_entry = ""; tr_raw = ""; tr_sep = arg.tr_sep } in let cygwin path = - let contains_in dir item = + let contains_in {tr_entry = dir; _} item = Sys.file_exists (Filename.concat dir item) in let shadow_list = List.filter (contains_in arg) - ["bash.exe"; "sort.exe"; "tar.exe"; "git.exe"] + ["bash.exe"; "sort.exe"; "tar.exe"; "git.exe"] in - let rec loop acc = function + let rec loop acc = function | [] -> acc, [arg] | (d::rest) as suffix -> - if List.exists (contains_in d) shadow_list then - acc, arg::suffix - else - loop (d::acc) rest - in - loop [] path + if List.exists (contains_in d) shadow_list then + acc, arg::suffix + else + loop (d::acc) rest + in + loop [] path in match op with - | Eq -> [],[arg] - | PlusEq -> [], arg :: rezip zip - | EqPlus -> List.rev_append l2 rl1, [arg] + | Eq -> + (* Existing zip discarded - new value to l2; no prefix *) + [], [arg] + | PlusEq -> + (* New value goes at head of existing list; no prefix *) + begin match rezip zip with + | [{ tr_entry = ""; tr_raw = raw; _}] -> + if raw = "" then + [], [arg] + else + [], [arg; empty_tr] + | zip -> [], arg::zip + end + | EqPlus -> + (* NB List.rev_append l2 rl1 is equivalent to + List.rev (List.rev_append rl1 l2) + Place new value at the end *) + begin match List.rev_append l2 rl1 with + | [{ tr_entry = ""; tr_raw = raw; _}] -> + if raw = "" then + [], [arg] + else + [], [empty_tr; arg] + | zip -> zip, [arg] + end | Cygwin -> - cygwin (List.rev_append rl1 l2) - | EqPlusEq -> rl1, arg::l2 + cygwin (rezip zip) + | EqPlusEq -> + (* Add the value where the last value was reverted (i.e. as PlusEq but + without the rezip) *) + rl1, arg::l2 | ColonEq -> - let l, add = colon_eq (rezip zip) in [], add @ l + begin match rezip zip with + | [{ tr_entry = ""; _}] | [] -> (* empty or unset *) + [], [arg; empty_tr] + | ({ tr_entry = ""; _} as lead)::{ tr_entry = ""; _}::([] as zip) -> + (* VAR=':' *) + [], lead::arg::zip + | zip -> + [], arg::zip + end | EqColon -> - let l, add = colon_eq ~eqcol:true (List.rev_append l2 rl1) in - l, List.rev add + begin match List.rev_append l2 rl1 with + | [{ tr_entry = ""; _}] | [] -> (* empty or unset *) + [], [empty_tr; arg] + | ({ tr_entry = ""; _} as lead)::{ tr_entry = ""; _}::([] as zip) -> + (* VAR=':' *) + [], List.rev (lead::arg::zip) + | zip -> + [], List.rev (arg::zip) + end (** Undoes previous updates done by opam, useful for not duplicating already done updates; this is obviously not perfect, as all operators are not @@ -285,24 +392,25 @@ let apply_op_zip ~sepfmt op arg (rl1,l2 as zip) = or empty lists is returned if the variable should be unset or has an unknown previous value. *) let reverse_env_update ~sepfmt var op arg cur_value = - if String.equal arg "" && op <> Eq then None else + let { tr_entry = arg; _} = transform_format ~sepfmt var arg in + if String.equal arg "" && op <> Eq then None else match op with | Eq -> - if arg = join_var ~sepfmt var cur_value + if arg = join_var cur_value then Some ([],[]) else None | PlusEq | EqPlusEq -> unzip_to var ~sepfmt arg cur_value | EqPlus | Cygwin -> (match unzip_to ~sepfmt var arg (List.rev cur_value) with | None -> None - | Some (rl1, l2) -> Some (List.rev l2, List.rev rl1)) + | Some (rl1, l2) -> Some (l2, List.rev rl1)) | ColonEq -> (match unzip_to var ~sepfmt arg cur_value with - | Some ([], [""]) -> Some ([], []) + | Some ([], [{ tr_entry = ""; _}]) -> Some ([], []) | r -> r) | EqColon -> (match unzip_to ~sepfmt var arg (List.rev cur_value) with - | Some ([], [""]) -> Some ([], []) - | Some (rl1, l2) -> Some (List.rev l2, List.rev rl1) + | Some ([], [{ tr_entry = ""; _}]) -> Some ([], []) + | Some (rl1, l2) -> Some (l2, List.rev rl1) | None -> None) let map_update_names env_keys updates = @@ -440,7 +548,7 @@ let expand updates = in let acc = if String.equal arg "" && op <> Eq then acc else - ((var, apply_op_zip ~sepfmt op arg zip, doc, sepfmt) + ((var, apply_op_zip ~sepfmt var op arg zip, doc, sepfmt) :: acc) in apply_updates @@ -450,10 +558,10 @@ let expand updates = | [] -> List.rev @@ List.rev_append - (List.rev_map (fun (var, z, doc, sepfmt) -> - var, rezip_to_string ~sepfmt var z, doc) acc) - @@ List.rev_map (fun (var, z, sepfmt) -> - var, rezip_to_string ~sepfmt var z, + (List.rev_map (fun (var, z, doc, _sepfmt) -> + var, rezip_to_string z, doc) acc) + @@ List.rev_map (fun (var, z, _sepfmt) -> + var, rezip_to_string z, Some "Reverting previous opam update") reverts in @@ -493,6 +601,14 @@ let env_expansion ?opam st upd = in { upd with envu_value = s } +(* [env_update_resolved_with_default] creates an environment update with a fully + evaluated rewrite rule. It's used internally because the updates in question + are single directories only, which means that the update will then never be + subject to splitting in [unzip_to] *) +let env_update_resolved_with_default ?comment var = + let rewrite = Some (SPF_Resolved (Some (default_sep_fmt_str var))) in + env_update_resolved ?comment ~rewrite var + let compute_updates ?(force_path=false) st = (* Todo: put these back into their packages! let perl5 = OpamPackage.Name.of_string "perl5" in @@ -503,18 +619,18 @@ let compute_updates ?(force_path=false) st = OpamPath.Switch.bin st.switch_global.root st.switch st.switch_config in let path = - env_update_resolved "PATH" + env_update_resolved_with_default "PATH" (if force_path then PlusEq else EqPlusEq) (OpamFilename.Dir.to_string bindir) ~comment:("Binary dir for opam switch "^OpamSwitch.to_string st.switch) - in + in let man_path = let open OpamStd.Sys in match os () with | OpenBSD | NetBSD | FreeBSD | Darwin | DragonFly -> [] (* MANPATH is a global override on those, so disabled for now *) | _ -> - [ env_update_resolved "MANPATH" EqColon + [ env_update_resolved_with_default "MANPATH" EqColon (OpamFilename.Dir.to_string (OpamPath.Switch.man_dir st.switch_global.root st.switch st.switch_config)) @@ -522,7 +638,7 @@ let compute_updates ?(force_path=false) st = ] in let switch_env = - (env_update_resolved "OPAM_SWITCH_PREFIX" Eq + (env_update_resolved_with_default "OPAM_SWITCH_PREFIX" Eq (OpamFilename.Dir.to_string (OpamPath.Switch.root st.switch_global.root st.switch)) ~comment:"Prefix of the current opam switch") @@ -545,14 +661,14 @@ let compute_updates ?(force_path=false) st = let updates_common ~set_opamroot ~set_opamswitch root switch = let root = if set_opamroot then - [ env_update_resolved "OPAMROOT" Eq + [ env_update_resolved_with_default "OPAMROOT" Eq (OpamFilename.Dir.to_string root) ~comment:"Opam root in use" ] else [] in let switch = if set_opamswitch then - [ env_update_resolved "OPAMSWITCH" Eq + [ env_update_resolved_with_default "OPAMSWITCH" Eq (OpamSwitch.to_string switch) ] else [] in root @ switch @@ -672,7 +788,7 @@ let switch_path_update ~force_path root switch = (OpamStateConfig.Switch.safe_load_t ~lock_kind:`Lock_read root switch) in - [ env_update_resolved "PATH" + [ env_update_resolved_with_default "PATH" (if force_path then PlusEq else EqPlusEq) (OpamFilename.Dir.to_string bindir) ~comment:"Current opam switch binary dir" ] @@ -974,15 +1090,8 @@ let string_of_update st shell updates = | Some (SPF_Resolved None) -> `rewrite_default envu_var | Some (SPF_Resolved (Some spf)) -> `rewrite spf in - let string = - transform_format ~sepfmt string - in - let sep = - OpamTypesBase.char_of_separator - (match envu_rewrite with - | Some (SPF_Resolved (Some (sep, _))) -> sep - | None | Some (SPF_Resolved None) -> - fst @@ default_sep_fmt_str envu_var) + let { tr_raw = string; tr_sep = sep; _} = + transform_format ~sepfmt (OpamStd.Env.Name.of_string envu_var) string in let key, value = envu_var, match (envu_op : euok_writeable env_update_op_kind) with diff --git a/tests/reftests/env.test b/tests/reftests/env.test index 03e8a357ad5..9dd62d28083 100644 --- a/tests/reftests/env.test +++ b/tests/reftests/env.test @@ -40,9 +40,9 @@ Done. ### opam env | grep NV_VARS NV_VARS='hej!!'; export NV_VARS; ### : opam env and its revert : -### opam exec -- opam env | grep "^NV_VARS|^OPAM_SWITCH_PREFIX|${OPAM}" -OPAM_SWITCH_PREFIX='${BASEDIR}/OPAM/conffile'; export OPAM_SWITCH_PREFIX; +### opam exec -- opam env | sort | grep "^NV_VARS|^OPAM_SWITCH_PREFIX|${OPAM}" NV_VARS='hej!!'; export NV_VARS; +OPAM_SWITCH_PREFIX='${BASEDIR}/OPAM/conffile'; export OPAM_SWITCH_PREFIX; ### opam exec -- opam env --revert | grep "^NV_VARS|^OPAM_SWITCH_PREFIX|${OPAM}" OPAM_SWITCH_PREFIX=''; export OPAM_SWITCH_PREFIX; NV_VARS=''; export NV_VARS; @@ -72,6 +72,22 @@ Done. V1.2.3 ### : empty environment variables update : ### NV_VARS='' +### NV_VARS_5926_L_2=:a +### NV_VARS_5926_L_4=:a +### NV_VARS_5926_L_6=:a +### NV_VARS_5926_L_8=:a +### NV_VARS_5926_M_1=a1::a2 +### NV_VARS_5926_M_2=a1::a2 +### NV_VARS_5926_M_3=a1::a2 +### NV_VARS_5926_M_4=a1::a2 +### NV_VARS_5926_S_1=: +### NV_VARS_5926_S_2=: +### NV_VARS_5926_S_3=: +### NV_VARS_5926_S_4=: +### NV_VARS_5926_T_2=a: +### NV_VARS_5926_T_4=a: +### NV_VARS_5926_T_6=a: +### NV_VARS_5926_T_8=a: ### opam-version: "2.0" setenv: [ @@ -81,8 +97,89 @@ setenv: [ [ NV_VARS3 := "foo" ] [ NV_VARS4 = "" ] [ NV_VARS5 += "" ] # undefined in the environment + [ NV_VARS_5925_1 = "" ] + [ NV_VARS_5925_1 += "foo" ] # initialised to "" by opam + [ NV_VARS_5925_2 += "foo" ] # unset in the environment + [ NV_VARS_5925_3 = "" ] + [ NV_VARS_5925_3 =+ "foo" ] # initialised to "" by opam + [ NV_VARS_5925_4 =+ "foo" ] # unset in the environment + [ NV_VARS_5925_5 = "" ] + [ NV_VARS_5925_5 := "foo" ] # initialised to "" by opam + [ NV_VARS_5925_6 := "foo" ] # unset in the environment + [ NV_VARS_5925_7 = "" ] + [ NV_VARS_5925_7 =: "foo" ] # initialised to "" by opam + [ NV_VARS_5925_8 =: "foo" ] # unset in the environment + # 5926 - these tests are all performed on non-empty environment variables + # (modulo that some tests initialise the variable in the environment + # and others "initialise" it using the correct behaviour of := or =: + # on an unset variable) and therefore the behaviour of += and := + # (or =+ and =:) should be the same. + # 5926 - opam preserves leading entry in a variable + [ NV_VARS_5926_L_1 =: "a" ] + [ NV_VARS_5926_L_1 += "b" ] # initialised to ":a" by opam + [ NV_VARS_5926_L_2 += "b" ] # set to ":a" in the environment |- b::a + [ NV_VARS_5926_L_3 =: "a" ] + [ NV_VARS_5926_L_3 =+ "b" ] # initialised to ":a" by opam + [ NV_VARS_5926_L_4 =+ "b" ] # set to ":a" in the environment |- :a:b + [ NV_VARS_5926_L_5 =: "a" ] + [ NV_VARS_5926_L_5 := "b" ] # initialised to ":a" by opam + [ NV_VARS_5926_L_6 := "b" ] # set to ":a" in the environment |- as for += + [ NV_VARS_5926_L_7 =: "a" ] + [ NV_VARS_5926_L_7 =: "b" ] # initialised to ":a" by opam + [ NV_VARS_5926_L_8 =: "b" ] # set to ":a" in the environment |- as for =+ + # 5926 - opam preserves middle empty entry in a variable + # (opam - intentionally - can't synthesise these) + [ NV_VARS_5926_M_1 += "b" ] # |- b:a1::a2 + [ NV_VARS_5926_M_2 =+ "b" ] # |- a1::a2:b + [ NV_VARS_5926_M_3 := "b" ] # |- as for += + [ NV_VARS_5926_M_4 =: "b" ] # |- as for =+ + # 5926 - opam preserves a solitary separator + # (opam - intentionally - can't synthesise these) + [ NV_VARS_5926_S_1 += "a" ] # |- a: + [ NV_VARS_5926_S_2 =+ "a" ] # |- :a + [ NV_VARS_5926_S_3 := "a" ] # |- as for += + [ NV_VARS_5926_S_4 =: "a" ] # |- as for =+ + # #5926 - opam preserves trailing entry in a variable + [ NV_VARS_5926_T_1 := "a" ] + [ NV_VARS_5926_T_1 += "b" ] # initialised to "a:" by opam + [ NV_VARS_5926_T_2 += "b" ] # set to "a:" in the environment |- b:a: + [ NV_VARS_5926_T_3 := "a" ] + [ NV_VARS_5926_T_3 =+ "b" ] # initialised to "a:" by opam + [ NV_VARS_5926_T_4 =+ "b" ] # set to "a:" in the environment |- a::b + [ NV_VARS_5926_T_5 := "a" ] + [ NV_VARS_5926_T_5 := "b" ] # initialised to "a:" by opam + [ NV_VARS_5926_T_6 := "b" ] # set to "a:" in the environment |- as for += + [ NV_VARS_5926_T_7 := "a" ] + [ NV_VARS_5926_T_7 =: "b" ] # initialised to "a:" by opam + [ NV_VARS_5926_T_8 =: "b" ] # set to "a:" in the environment |- as for =+ ] flags: compiler +x-env-path-rewrite: [ + [NV_VARS_5926_L_1 ":" "target"] + [NV_VARS_5926_L_2 ":" "target"] + [NV_VARS_5926_L_3 ":" "target"] + [NV_VARS_5926_L_4 ":" "target"] + [NV_VARS_5926_L_5 ":" "target"] + [NV_VARS_5926_L_6 ":" "target"] + [NV_VARS_5926_L_7 ":" "target"] + [NV_VARS_5926_L_8 ":" "target"] + [NV_VARS_5926_M_1 ":" "target"] + [NV_VARS_5926_M_2 ":" "target"] + [NV_VARS_5926_M_3 ":" "target"] + [NV_VARS_5926_M_4 ":" "target"] + [NV_VARS_5926_S_1 ":" "target"] + [NV_VARS_5926_S_2 ":" "target"] + [NV_VARS_5926_S_3 ":" "target"] + [NV_VARS_5926_S_4 ":" "target"] + [NV_VARS_5926_T_1 ":" "target"] + [NV_VARS_5926_T_2 ":" "target"] + [NV_VARS_5926_T_3 ":" "target"] + [NV_VARS_5926_T_4 ":" "target"] + [NV_VARS_5926_T_5 ":" "target"] + [NV_VARS_5926_T_6 ":" "target"] + [NV_VARS_5926_T_7 ":" "target"] + [NV_VARS_5926_T_8 ":" "target"] +] ### opam switch create emptyvar nv <><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><> @@ -95,12 +192,108 @@ Done. NV_VARS= NV_VARS3=foo: NV_VARS4= -### opam env | grep "NV_VARS" | ';' -> ':' +NV_VARS_5925_1=foo +NV_VARS_5925_2=foo +NV_VARS_5925_3=foo +NV_VARS_5925_4=foo +NV_VARS_5925_5=foo: +NV_VARS_5925_6=foo: +NV_VARS_5925_7=:foo +NV_VARS_5925_8=:foo +NV_VARS_5926_L_1=b::a +NV_VARS_5926_L_2=b::a +NV_VARS_5926_L_3=:a:b +NV_VARS_5926_L_4=:a:b +NV_VARS_5926_L_5=b::a +NV_VARS_5926_L_6=b::a +NV_VARS_5926_L_7=:a:b +NV_VARS_5926_L_8=:a:b +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_3=a: +NV_VARS_5926_S_4=:a +NV_VARS_5926_T_1=b:a: +NV_VARS_5926_T_2=b:a: +NV_VARS_5926_T_3=a::b +NV_VARS_5926_T_4=a::b +NV_VARS_5926_T_5=b:a: +NV_VARS_5926_T_6=b:a: +NV_VARS_5926_T_7=a::b +NV_VARS_5926_T_8=a::b +### opam env | sort | grep "NV_VARS" | ';' -> ':' NV_VARS3='foo:': export NV_VARS3: NV_VARS4='': export NV_VARS4: +NV_VARS_5925_1='foo': export NV_VARS_5925_1: +NV_VARS_5925_2='foo': export NV_VARS_5925_2: +NV_VARS_5925_3='foo': export NV_VARS_5925_3: +NV_VARS_5925_4='foo': export NV_VARS_5925_4: +NV_VARS_5925_5='foo:': export NV_VARS_5925_5: +NV_VARS_5925_6='foo:': export NV_VARS_5925_6: +NV_VARS_5925_7=':foo': export NV_VARS_5925_7: +NV_VARS_5925_8=':foo': export NV_VARS_5925_8: +NV_VARS_5926_L_1='b::a': export NV_VARS_5926_L_1: +NV_VARS_5926_L_2='b::a': export NV_VARS_5926_L_2: +NV_VARS_5926_L_3=':a:b': export NV_VARS_5926_L_3: +NV_VARS_5926_L_4=':a:b': export NV_VARS_5926_L_4: +NV_VARS_5926_L_5='b::a': export NV_VARS_5926_L_5: +NV_VARS_5926_L_6='b::a': export NV_VARS_5926_L_6: +NV_VARS_5926_L_7=':a:b': export NV_VARS_5926_L_7: +NV_VARS_5926_L_8=':a:b': export NV_VARS_5926_L_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_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: +NV_VARS_5926_T_2='b:a:': export NV_VARS_5926_T_2: +NV_VARS_5926_T_3='a::b': export NV_VARS_5926_T_3: +NV_VARS_5926_T_4='a::b': export NV_VARS_5926_T_4: +NV_VARS_5926_T_5='b:a:': export NV_VARS_5926_T_5: +NV_VARS_5926_T_6='b:a:': export NV_VARS_5926_T_6: +NV_VARS_5926_T_7='a::b': export NV_VARS_5926_T_7: +NV_VARS_5926_T_8='a::b': export NV_VARS_5926_T_8: ### opam exec -- opam env --revert | grep "NV_VARS" | ';' -> ':' NV_VARS3='': export NV_VARS3: NV_VARS4='': export NV_VARS4: +NV_VARS_5925_1='': export NV_VARS_5925_1: +NV_VARS_5925_2='': export NV_VARS_5925_2: +NV_VARS_5925_3='': export NV_VARS_5925_3: +NV_VARS_5925_4='': export NV_VARS_5925_4: +NV_VARS_5925_5='': export NV_VARS_5925_5: +NV_VARS_5925_6='': export NV_VARS_5925_6: +NV_VARS_5925_7='': export NV_VARS_5925_7: +NV_VARS_5925_8='': export NV_VARS_5925_8: +NV_VARS_5926_L_1='': export NV_VARS_5926_L_1: +NV_VARS_5926_L_2=':a': export NV_VARS_5926_L_2: +NV_VARS_5926_L_3='': export NV_VARS_5926_L_3: +NV_VARS_5926_L_4=':a': export NV_VARS_5926_L_4: +NV_VARS_5926_L_5='': export NV_VARS_5926_L_5: +NV_VARS_5926_L_6=':a': export NV_VARS_5926_L_6: +NV_VARS_5926_L_7='': export NV_VARS_5926_L_7: +NV_VARS_5926_L_8=':a': export NV_VARS_5926_L_8: +NV_VARS_5926_M_1='a1::a2': export NV_VARS_5926_M_1: +NV_VARS_5926_M_2='a1::a2': export NV_VARS_5926_M_2: +NV_VARS_5926_M_3='a1::a2': export NV_VARS_5926_M_3: +NV_VARS_5926_M_4='a1::a2': export NV_VARS_5926_M_4: +NV_VARS_5926_S_1='': export NV_VARS_5926_S_1: +NV_VARS_5926_S_2='': export NV_VARS_5926_S_2: +NV_VARS_5926_S_3='': export NV_VARS_5926_S_3: +NV_VARS_5926_S_4='': export NV_VARS_5926_S_4: +NV_VARS_5926_T_1='': export NV_VARS_5926_T_1: +NV_VARS_5926_T_2='a:': export NV_VARS_5926_T_2: +NV_VARS_5926_T_3='': export NV_VARS_5926_T_3: +NV_VARS_5926_T_4='a:': export NV_VARS_5926_T_4: +NV_VARS_5926_T_5='': export NV_VARS_5926_T_5: +NV_VARS_5926_T_6='a:': export NV_VARS_5926_T_6: +NV_VARS_5926_T_7='': export NV_VARS_5926_T_7: +NV_VARS_5926_T_8='a:': export NV_VARS_5926_T_8: ### NV_VARS=/another/path ### NV_VARS2=/another/different/path ### NV_VARS3=/yet/another/different/path @@ -110,12 +303,108 @@ NV_VARS=/another/path NV_VARS2=/another/different/path NV_VARS3=foo:/yet/another/different/path NV_VARS4= -### opam env | grep "NV_VARS" | ';' -> ':' +NV_VARS_5925_1=foo +NV_VARS_5925_2=foo +NV_VARS_5925_3=foo +NV_VARS_5925_4=foo +NV_VARS_5925_5=foo: +NV_VARS_5925_6=foo: +NV_VARS_5925_7=:foo +NV_VARS_5925_8=:foo +NV_VARS_5926_L_1=b::a +NV_VARS_5926_L_2=b::a +NV_VARS_5926_L_3=:a:b +NV_VARS_5926_L_4=:a:b +NV_VARS_5926_L_5=b::a +NV_VARS_5926_L_6=b::a +NV_VARS_5926_L_7=:a:b +NV_VARS_5926_L_8=:a:b +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_3=a: +NV_VARS_5926_S_4=:a +NV_VARS_5926_T_1=b:a: +NV_VARS_5926_T_2=b:a: +NV_VARS_5926_T_3=a::b +NV_VARS_5926_T_4=a::b +NV_VARS_5926_T_5=b:a: +NV_VARS_5926_T_6=b:a: +NV_VARS_5926_T_7=a::b +NV_VARS_5926_T_8=a::b +### opam env | sort | grep "NV_VARS" | ';' -> ':' NV_VARS3='foo:/yet/another/different/path': export NV_VARS3: NV_VARS4='': export NV_VARS4: +NV_VARS_5925_1='foo': export NV_VARS_5925_1: +NV_VARS_5925_2='foo': export NV_VARS_5925_2: +NV_VARS_5925_3='foo': export NV_VARS_5925_3: +NV_VARS_5925_4='foo': export NV_VARS_5925_4: +NV_VARS_5925_5='foo:': export NV_VARS_5925_5: +NV_VARS_5925_6='foo:': export NV_VARS_5925_6: +NV_VARS_5925_7=':foo': export NV_VARS_5925_7: +NV_VARS_5925_8=':foo': export NV_VARS_5925_8: +NV_VARS_5926_L_1='b::a': export NV_VARS_5926_L_1: +NV_VARS_5926_L_2='b::a': export NV_VARS_5926_L_2: +NV_VARS_5926_L_3=':a:b': export NV_VARS_5926_L_3: +NV_VARS_5926_L_4=':a:b': export NV_VARS_5926_L_4: +NV_VARS_5926_L_5='b::a': export NV_VARS_5926_L_5: +NV_VARS_5926_L_6='b::a': export NV_VARS_5926_L_6: +NV_VARS_5926_L_7=':a:b': export NV_VARS_5926_L_7: +NV_VARS_5926_L_8=':a:b': export NV_VARS_5926_L_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_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: +NV_VARS_5926_T_2='b:a:': export NV_VARS_5926_T_2: +NV_VARS_5926_T_3='a::b': export NV_VARS_5926_T_3: +NV_VARS_5926_T_4='a::b': export NV_VARS_5926_T_4: +NV_VARS_5926_T_5='b:a:': export NV_VARS_5926_T_5: +NV_VARS_5926_T_6='b:a:': export NV_VARS_5926_T_6: +NV_VARS_5926_T_7='a::b': export NV_VARS_5926_T_7: +NV_VARS_5926_T_8='a::b': export NV_VARS_5926_T_8: ### opam exec -- opam env --revert | grep "NV_VARS" | ';' -> ':' NV_VARS3='/yet/another/different/path': export NV_VARS3: NV_VARS4='': export NV_VARS4: +NV_VARS_5925_1='': export NV_VARS_5925_1: +NV_VARS_5925_2='': export NV_VARS_5925_2: +NV_VARS_5925_3='': export NV_VARS_5925_3: +NV_VARS_5925_4='': export NV_VARS_5925_4: +NV_VARS_5925_5='': export NV_VARS_5925_5: +NV_VARS_5925_6='': export NV_VARS_5925_6: +NV_VARS_5925_7='': export NV_VARS_5925_7: +NV_VARS_5925_8='': export NV_VARS_5925_8: +NV_VARS_5926_L_1='': export NV_VARS_5926_L_1: +NV_VARS_5926_L_2=':a': export NV_VARS_5926_L_2: +NV_VARS_5926_L_3='': export NV_VARS_5926_L_3: +NV_VARS_5926_L_4=':a': export NV_VARS_5926_L_4: +NV_VARS_5926_L_5='': export NV_VARS_5926_L_5: +NV_VARS_5926_L_6=':a': export NV_VARS_5926_L_6: +NV_VARS_5926_L_7='': export NV_VARS_5926_L_7: +NV_VARS_5926_L_8=':a': export NV_VARS_5926_L_8: +NV_VARS_5926_M_1='a1::a2': export NV_VARS_5926_M_1: +NV_VARS_5926_M_2='a1::a2': export NV_VARS_5926_M_2: +NV_VARS_5926_M_3='a1::a2': export NV_VARS_5926_M_3: +NV_VARS_5926_M_4='a1::a2': export NV_VARS_5926_M_4: +NV_VARS_5926_S_1='': export NV_VARS_5926_S_1: +NV_VARS_5926_S_2='': export NV_VARS_5926_S_2: +NV_VARS_5926_S_3='': export NV_VARS_5926_S_3: +NV_VARS_5926_S_4='': export NV_VARS_5926_S_4: +NV_VARS_5926_T_1='': export NV_VARS_5926_T_1: +NV_VARS_5926_T_2='a:': export NV_VARS_5926_T_2: +NV_VARS_5926_T_3='': export NV_VARS_5926_T_3: +NV_VARS_5926_T_4='a:': export NV_VARS_5926_T_4: +NV_VARS_5926_T_5='': export NV_VARS_5926_T_5: +NV_VARS_5926_T_6='a:': export NV_VARS_5926_T_6: +NV_VARS_5926_T_7='': export NV_VARS_5926_T_7: +NV_VARS_5926_T_8='a:': export NV_VARS_5926_T_8: ### : Full revert of uninstalled package with setenv : ### opam-version: "2.0" @@ -171,6 +460,38 @@ Done. ### opam env --root "$RT" --switch "./$SW" | grep "NV_VARS" | ';' -> ':' NV_VARS3='foo:/yet/another/different/path': export NV_VARS3: NV_VARS4='': export NV_VARS4: +NV_VARS_5925_1='foo': export NV_VARS_5925_1: +NV_VARS_5925_2='foo': export NV_VARS_5925_2: +NV_VARS_5925_3='foo': export NV_VARS_5925_3: +NV_VARS_5925_4='foo': export NV_VARS_5925_4: +NV_VARS_5925_5='foo:': export NV_VARS_5925_5: +NV_VARS_5925_6='foo:': export NV_VARS_5925_6: +NV_VARS_5925_7=':foo': export NV_VARS_5925_7: +NV_VARS_5925_8=':foo': export NV_VARS_5925_8: +NV_VARS_5926_L_1='b::a': export NV_VARS_5926_L_1: +NV_VARS_5926_L_2='b::a': export NV_VARS_5926_L_2: +NV_VARS_5926_L_3=':a:b': export NV_VARS_5926_L_3: +NV_VARS_5926_L_4=':a:b': export NV_VARS_5926_L_4: +NV_VARS_5926_L_5='b::a': export NV_VARS_5926_L_5: +NV_VARS_5926_L_6='b::a': export NV_VARS_5926_L_6: +NV_VARS_5926_L_7=':a:b': export NV_VARS_5926_L_7: +NV_VARS_5926_L_8=':a:b': export NV_VARS_5926_L_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_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: +NV_VARS_5926_T_2='b:a:': export NV_VARS_5926_T_2: +NV_VARS_5926_T_3='a::b': export NV_VARS_5926_T_3: +NV_VARS_5926_T_4='a::b': export NV_VARS_5926_T_4: +NV_VARS_5926_T_5='b:a:': export NV_VARS_5926_T_5: +NV_VARS_5926_T_6='b:a:': export NV_VARS_5926_T_6: +NV_VARS_5926_T_7='a::b': export NV_VARS_5926_T_7: +NV_VARS_5926_T_8='a::b': export NV_VARS_5926_T_8: ### OPAMNOENVNOTICE=1 ### : Env hooks : ### diff --git a/tests/reftests/env.unix.test b/tests/reftests/env.unix.test index ad6fe4133a6..eaa9395e32c 100644 --- a/tests/reftests/env.unix.test +++ b/tests/reftests/env.unix.test @@ -24,7 +24,7 @@ build-env: [ [ RCT_ENVBUILD_ADD += "/a/given/path" ] [ RCT_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RCT_ENV" ] +build: [ "sh" "-c" "env | grep RCT_ENV | sort" ] x-env-path-rewrite: [ [ RCT_ENVSET ":" "target" ] [ RCT_ENVSET_STR ":" "target" ] @@ -44,8 +44,8 @@ The following actions will be performed: - install col-target 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [col-target: sh env | grep RCT_ENV] -+ sh "-c" "env | grep RCT_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-target.1) +Processing 2/3: [col-target: sh env | grep RCT_ENV | sort] ++ sh "-c" "env | grep RCT_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-target.1) - RCT_ENVBUILD=/a/given/path - RCT_ENVBUILD_ADD=/a/given/path:a/path/to - RCT_ENVBUILD_ADD_WITH_COL=a:/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted" @@ -56,12 +56,12 @@ Processing 2/3: [col-target: sh env | grep RCT_ENV] -> compiled col-target.1 -> installed col-target.1 Done. -### opam env | grep "RCT_ENV" +### opam env | sort | grep "RCT_ENV" RCT_ENVSET='/a/given/path'; export RCT_ENVSET; -RCT_ENVSET_STR='something'; export RCT_ENVSET_STR; -RCT_ENVSET_WITH_COL='s:mething'; export RCT_ENVSET_WITH_COL; RCT_ENVSET_ADD='/a/given/path:a/path/to'; export RCT_ENVSET_ADD; RCT_ENVSET_ADD_WITH_COL='a:/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted"'; export RCT_ENVSET_ADD_WITH_COL; +RCT_ENVSET_STR='something'; export RCT_ENVSET_STR; +RCT_ENVSET_WITH_COL='s:mething'; export RCT_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RCT_ENV RCT_ENVSET = /a/given/path : target Updated\ by\ package\ col-target RCT_ENVSET_STR = something : target Updated\ by\ package\ col-target @@ -91,7 +91,7 @@ build-env: [ [ RCTQ_ENVBUILD_ADD += "/a/given/path" ] [ RCTQ_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RCTQ_ENV" ] +build: [ "sh" "-c" "env | grep RCTQ_ENV | sort" ] x-env-path-rewrite: [ [ RCTQ_ENVSET ":" "target-quoted" ] [ RCTQ_ENVSET_STR ":" "target-quoted" ] @@ -111,8 +111,8 @@ The following actions will be performed: - install col-target-quoted 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [col-target-quoted: sh env | grep RCTQ_ENV] -+ sh "-c" "env | grep RCTQ_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-target-quoted.1) +Processing 2/3: [col-target-quoted: sh env | grep RCTQ_ENV | sort] ++ sh "-c" "env | grep RCTQ_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-target-quoted.1) - RCTQ_ENVBUILD=/a/given/path - RCTQ_ENVBUILD_ADD=/a/given/path:a/path/to - RCTQ_ENVBUILD_ADD_WITH_COL="a:/nother/gi;ven/path":/a/path/to:"t:/his/is/quoted" @@ -123,12 +123,12 @@ Processing 2/3: [col-target-quoted: sh env | grep RCTQ_ENV] -> compiled col-target-quoted.1 -> installed col-target-quoted.1 Done. -### opam env | grep "RCTQ_ENV" +### opam env | sort | grep "RCTQ_ENV" RCTQ_ENVSET='/a/given/path'; export RCTQ_ENVSET; -RCTQ_ENVSET_STR='something'; export RCTQ_ENVSET_STR; -RCTQ_ENVSET_WITH_COL='"s:mething"'; export RCTQ_ENVSET_WITH_COL; RCTQ_ENVSET_ADD='/a/given/path:a/path/to'; export RCTQ_ENVSET_ADD; RCTQ_ENVSET_ADD_WITH_COL='"a:/nother/gi;ven/path":/a/path/to:"t:/his/is/quoted"'; export RCTQ_ENVSET_ADD_WITH_COL; +RCTQ_ENVSET_STR='something'; export RCTQ_ENVSET_STR; +RCTQ_ENVSET_WITH_COL='"s:mething"'; export RCTQ_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RCTQ_ENV RCTQ_ENVSET = /a/given/path : target-quoted Updated\ by\ package\ col-target-quoted RCTQ_ENVSET_STR = something : target-quoted Updated\ by\ package\ col-target-quoted @@ -158,7 +158,7 @@ build-env: [ [ RCH_ENVBUILD_ADD += "/a/given/path" ] [ RCH_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RCH_ENV" ] +build: [ "sh" "-c" "env | grep RCH_ENV | sort" ] x-env-path-rewrite: [ [ RCH_ENVSET ":" "host" ] [ RCH_ENVSET_STR ":" "host" ] @@ -178,8 +178,8 @@ The following actions will be performed: - install col-host 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [col-host: sh env | grep RCH_ENV] -+ sh "-c" "env | grep RCH_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-host.1) +Processing 2/3: [col-host: sh env | grep RCH_ENV | sort] ++ sh "-c" "env | grep RCH_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-host.1) - RCH_ENVBUILD=/a/given/path - RCH_ENVBUILD_ADD=/a/given/path:a/path/to - RCH_ENVBUILD_ADD_WITH_COL=a:/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted" @@ -190,12 +190,12 @@ Processing 2/3: [col-host: sh env | grep RCH_ENV] -> compiled col-host.1 -> installed col-host.1 Done. -### opam env | grep "RCH_ENV" +### opam env | sort | grep "RCH_ENV" RCH_ENVSET='/a/given/path'; export RCH_ENVSET; -RCH_ENVSET_STR='something'; export RCH_ENVSET_STR; -RCH_ENVSET_WITH_COL='s:mething'; export RCH_ENVSET_WITH_COL; RCH_ENVSET_ADD='/a/given/path:a/path/to'; export RCH_ENVSET_ADD; RCH_ENVSET_ADD_WITH_COL='a:/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted"'; export RCH_ENVSET_ADD_WITH_COL; +RCH_ENVSET_STR='something'; export RCH_ENVSET_STR; +RCH_ENVSET_WITH_COL='s:mething'; export RCH_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RCH_ENV RCH_ENVSET = /a/given/path : host Updated\ by\ package\ col-host RCH_ENVSET_STR = something : host Updated\ by\ package\ col-host @@ -225,7 +225,7 @@ build-env: [ [ RCHQ_ENVBUILD_ADD += "/a/given/path" ] [ RCHQ_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RCHQ_ENV" ] +build: [ "sh" "-c" "env | grep RCHQ_ENV | sort" ] x-env-path-rewrite: [ [ RCHQ_ENVSET ":" "host-quoted" ] [ RCHQ_ENVSET_STR ":" "host-quoted" ] @@ -245,8 +245,8 @@ The following actions will be performed: - install col-host-quoted 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [col-host-quoted: sh env | grep RCHQ_ENV] -+ sh "-c" "env | grep RCHQ_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-host-quoted.1) +Processing 2/3: [col-host-quoted: sh env | grep RCHQ_ENV | sort] ++ sh "-c" "env | grep RCHQ_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-host-quoted.1) - RCHQ_ENVBUILD=/a/given/path - RCHQ_ENVBUILD_ADD=/a/given/path:a/path/to - RCHQ_ENVBUILD_ADD_WITH_COL="a:/nother/gi;ven/path":/a/path/to:"t:/his/is/quoted" @@ -257,12 +257,12 @@ Processing 2/3: [col-host-quoted: sh env | grep RCHQ_ENV] -> compiled col-host-quoted.1 -> installed col-host-quoted.1 Done. -### opam env | grep "RCHQ_ENV" +### opam env | sort | grep "RCHQ_ENV" RCHQ_ENVSET='/a/given/path'; export RCHQ_ENVSET; -RCHQ_ENVSET_STR='something'; export RCHQ_ENVSET_STR; -RCHQ_ENVSET_WITH_COL='"s:mething"'; export RCHQ_ENVSET_WITH_COL; RCHQ_ENVSET_ADD='/a/given/path:a/path/to'; export RCHQ_ENVSET_ADD; RCHQ_ENVSET_ADD_WITH_COL='"a:/nother/gi;ven/path":/a/path/to:"t:/his/is/quoted"'; export RCHQ_ENVSET_ADD_WITH_COL; +RCHQ_ENVSET_STR='something'; export RCHQ_ENVSET_STR; +RCHQ_ENVSET_WITH_COL='"s:mething"'; export RCHQ_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RCHQ_ENV RCHQ_ENVSET = /a/given/path : host-quoted Updated\ by\ package\ col-host-quoted RCHQ_ENVSET_STR = something : host-quoted Updated\ by\ package\ col-host-quoted @@ -289,7 +289,7 @@ build-env: [ [ RST_ENVBUILD_ADD += "/a/given/path" ] [ RST_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RST_ENV" ] +build: [ "sh" "-c" "env | grep RST_ENV | sort" ] x-env-path-rewrite: [ [ RST_ENVSET ";" "target" ] [ RST_ENVSET_STR ";" "target" ] @@ -309,8 +309,8 @@ The following actions will be performed: - install semicol-target 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [semicol-target: sh env | grep RST_ENV] -+ sh "-c" "env | grep RST_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-target.1) +Processing 2/3: [semicol-target: sh env | grep RST_ENV | sort] ++ sh "-c" "env | grep RST_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-target.1) - RST_ENVBUILD=/a/given/path - RST_ENVBUILD_ADD=/a/given/path;a/path/to - RST_ENVBUILD_ADD_WITH_COL=a:/nother/gi;ven/path;/a/path/to;"t:/his/is/quoted" @@ -321,12 +321,12 @@ Processing 2/3: [semicol-target: sh env | grep RST_ENV] -> compiled semicol-target.1 -> installed semicol-target.1 Done. -### opam env | grep "RST_ENV" +### opam env | sort | grep "RST_ENV" RST_ENVSET='/a/given/path'; export RST_ENVSET; -RST_ENVSET_STR='something'; export RST_ENVSET_STR; -RST_ENVSET_WITH_COL='s:mething'; export RST_ENVSET_WITH_COL; RST_ENVSET_ADD='/a/given/path;a/path/to'; export RST_ENVSET_ADD; RST_ENVSET_ADD_WITH_COL='a:/nother/gi;ven/path;/a/path/to;"t:/his/is/quoted"'; export RST_ENVSET_ADD_WITH_COL; +RST_ENVSET_STR='something'; export RST_ENVSET_STR; +RST_ENVSET_WITH_COL='s:mething'; export RST_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RST_ENV RST_ENVSET = /a/given/path ; target Updated\ by\ package\ semicol-target RST_ENVSET_STR = something ; target Updated\ by\ package\ semicol-target @@ -356,7 +356,7 @@ build-env: [ [ RSTQ_ENVBUILD_ADD += "/a/given/path" ] [ RSTQ_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RSTQ_ENV" ] +build: [ "sh" "-c" "env | grep RSTQ_ENV | sort" ] x-env-path-rewrite: [ [ RSTQ_ENVSET ";" "target-quoted" ] [ RSTQ_ENVSET_STR ";" "target-quoted" ] @@ -376,8 +376,8 @@ The following actions will be performed: - install semicol-target-quoted 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [semicol-target-quoted: sh env | grep RSTQ_ENV] -+ sh "-c" "env | grep RSTQ_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-target-quoted.1) +Processing 2/3: [semicol-target-quoted: sh env | grep RSTQ_ENV | sort] ++ sh "-c" "env | grep RSTQ_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-target-quoted.1) - RSTQ_ENVBUILD=/a/given/path - RSTQ_ENVBUILD_ADD=/a/given/path;a/path/to - RSTQ_ENVBUILD_ADD_WITH_COL="a:/nother/gi;ven/path";/a/path/to;"t:/his/is/quoted" @@ -388,12 +388,12 @@ Processing 2/3: [semicol-target-quoted: sh env | grep RSTQ_ENV] -> compiled semicol-target-quoted.1 -> installed semicol-target-quoted.1 Done. -### opam env | grep "RSTQ_ENV" +### opam env | sort | grep "RSTQ_ENV" RSTQ_ENVSET='/a/given/path'; export RSTQ_ENVSET; -RSTQ_ENVSET_STR='something'; export RSTQ_ENVSET_STR; -RSTQ_ENVSET_WITH_COL='s:mething'; export RSTQ_ENVSET_WITH_COL; RSTQ_ENVSET_ADD='/a/given/path;a/path/to'; export RSTQ_ENVSET_ADD; RSTQ_ENVSET_ADD_WITH_COL='"a:/nother/gi;ven/path";/a/path/to;"t:/his/is/quoted"'; export RSTQ_ENVSET_ADD_WITH_COL; +RSTQ_ENVSET_STR='something'; export RSTQ_ENVSET_STR; +RSTQ_ENVSET_WITH_COL='s:mething'; export RSTQ_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RSTQ_ENV RSTQ_ENVSET = /a/given/path ; target-quoted Updated\ by\ package\ semicol-target-quoted RSTQ_ENVSET_STR = something ; target-quoted Updated\ by\ package\ semicol-target-quoted @@ -423,7 +423,7 @@ build-env: [ [ RSH_ENVBUILD_ADD += "/a/given/path" ] [ RSH_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RSH_ENV" ] +build: [ "sh" "-c" "env | grep RSH_ENV | sort" ] x-env-path-rewrite: [ [ RSH_ENVSET ";" "host" ] [ RSH_ENVSET_STR ";" "host" ] @@ -443,8 +443,8 @@ The following actions will be performed: - install semicol-host 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [semicol-host: sh env | grep RSH_ENV] -+ sh "-c" "env | grep RSH_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-host.1) +Processing 2/3: [semicol-host: sh env | grep RSH_ENV | sort] ++ sh "-c" "env | grep RSH_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-host.1) - RSH_ENVBUILD=/a/given/path - RSH_ENVBUILD_ADD=/a/given/path;a/path/to - RSH_ENVBUILD_ADD_WITH_COL=a:/nother/gi;ven/path;/a/path/to;"t:/his/is/quoted" @@ -455,12 +455,12 @@ Processing 2/3: [semicol-host: sh env | grep RSH_ENV] -> compiled semicol-host.1 -> installed semicol-host.1 Done. -### opam env | grep "RSH_ENV" +### opam env | sort | grep "RSH_ENV" RSH_ENVSET='/a/given/path'; export RSH_ENVSET; -RSH_ENVSET_STR='something'; export RSH_ENVSET_STR; -RSH_ENVSET_WITH_COL='s:mething'; export RSH_ENVSET_WITH_COL; RSH_ENVSET_ADD='/a/given/path;a/path/to'; export RSH_ENVSET_ADD; RSH_ENVSET_ADD_WITH_COL='a:/nother/gi;ven/path;/a/path/to;"t:/his/is/quoted"'; export RSH_ENVSET_ADD_WITH_COL; +RSH_ENVSET_STR='something'; export RSH_ENVSET_STR; +RSH_ENVSET_WITH_COL='s:mething'; export RSH_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RSH_ENV RSH_ENVSET = /a/given/path ; host Updated\ by\ package\ semicol-host RSH_ENVSET_STR = something ; host Updated\ by\ package\ semicol-host @@ -490,7 +490,7 @@ build-env: [ [ RSHQ_ENVBUILD_ADD += "/a/given/path" ] [ RSHQ_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RSHQ_ENV" ] +build: [ "sh" "-c" "env | grep RSHQ_ENV | sort" ] x-env-path-rewrite: [ [ RSHQ_ENVSET ";" "host-quoted" ] [ RSHQ_ENVSET_STR ";" "host-quoted" ] @@ -510,8 +510,8 @@ The following actions will be performed: - install semicol-host-quoted 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [semicol-host-quoted: sh env | grep RSHQ_ENV] -+ sh "-c" "env | grep RSHQ_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-host-quoted.1) +Processing 2/3: [semicol-host-quoted: sh env | grep RSHQ_ENV | sort] ++ sh "-c" "env | grep RSHQ_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-host-quoted.1) - RSHQ_ENVBUILD=/a/given/path - RSHQ_ENVBUILD_ADD=/a/given/path;a/path/to - RSHQ_ENVBUILD_ADD_WITH_COL="a:/nother/gi;ven/path";/a/path/to;"t:/his/is/quoted" @@ -522,12 +522,12 @@ Processing 2/3: [semicol-host-quoted: sh env | grep RSHQ_ENV] -> compiled semicol-host-quoted.1 -> installed semicol-host-quoted.1 Done. -### opam env | grep "RSHQ_ENV" +### opam env | sort | grep "RSHQ_ENV" RSHQ_ENVSET='/a/given/path'; export RSHQ_ENVSET; -RSHQ_ENVSET_STR='something'; export RSHQ_ENVSET_STR; -RSHQ_ENVSET_WITH_COL='s:mething'; export RSHQ_ENVSET_WITH_COL; RSHQ_ENVSET_ADD='/a/given/path;a/path/to'; export RSHQ_ENVSET_ADD; RSHQ_ENVSET_ADD_WITH_COL='"a:/nother/gi;ven/path";/a/path/to;"t:/his/is/quoted"'; export RSHQ_ENVSET_ADD_WITH_COL; +RSHQ_ENVSET_STR='something'; export RSHQ_ENVSET_STR; +RSHQ_ENVSET_WITH_COL='s:mething'; export RSHQ_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RSHQ_ENV RSHQ_ENVSET = /a/given/path ; host-quoted Updated\ by\ package\ semicol-host-quoted RSHQ_ENVSET_STR = something ; host-quoted Updated\ by\ package\ semicol-host-quoted @@ -557,7 +557,7 @@ build-env: [ [ RF_ENVBUILD_ADD += "/a/given/path" ] [ RF_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RF_ENV" ] +build: [ "sh" "-c" "env | grep RF_ENV | sort" ] x-env-path-rewrite: [ [ RF_ENVSET false ] [ RF_ENVSET_STR false ] @@ -577,8 +577,8 @@ The following actions will be performed: - install false 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [false: sh env | grep RF_ENV] -+ sh "-c" "env | grep RF_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/false.1) +Processing 2/3: [false: sh env | grep RF_ENV | sort] ++ sh "-c" "env | grep RF_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/false.1) - RF_ENVBUILD=/a/given/path - RF_ENVBUILD_ADD=/a/given/path:a/path/to - RF_ENVBUILD_ADD_WITH_COL=a:/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted" @@ -589,12 +589,12 @@ Processing 2/3: [false: sh env | grep RF_ENV] -> compiled false.1 -> installed false.1 Done. -### opam env | grep "RF_ENV" +### opam env | sort | grep "RF_ENV" RF_ENVSET='/a/given/path'; export RF_ENVSET; -RF_ENVSET_STR='something'; export RF_ENVSET_STR; -RF_ENVSET_WITH_COL='s:mething'; export RF_ENVSET_WITH_COL; RF_ENVSET_ADD='/a/given/path:a/path/to'; export RF_ENVSET_ADD; RF_ENVSET_ADD_WITH_COL='a:/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted"'; export RF_ENVSET_ADD_WITH_COL; +RF_ENVSET_STR='something'; export RF_ENVSET_STR; +RF_ENVSET_WITH_COL='s:mething'; export RF_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RF_ENV RF_ENVSET = /a/given/path norewrite Updated\ by\ package\ false RF_ENVSET_STR = something norewrite Updated\ by\ package\ false @@ -625,7 +625,7 @@ build-env: [ [ RO_ENVBUILD_COL_TARGET += "a:/nother/gi;ven/path" ] [ RO_ENVBUILD_COL_TARGET_QUOTED += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RO_ENV" ] +build: [ "sh" "-c" "env | grep RO_ENV | sort" ] x-env-path-rewrite: [ [ RO_ENVSET ":" "target" ] [ RO_ENVSET_STR_WS false ] @@ -646,8 +646,8 @@ The following actions will be performed: - install rewrite 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [rewrite: sh env | grep RO_ENV] -+ sh "-c" "env | grep RO_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/rewrite.1) +Processing 2/3: [rewrite: sh env | grep RO_ENV | sort] ++ sh "-c" "env | grep RO_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/rewrite.1) - RO_ENVBUILD=/another/given/path - RO_ENVBUILD_COL=s:mething - RO_ENVBUILD_COL_TARGET=a:/nother/gi;ven/path;a/path/to @@ -658,13 +658,13 @@ Processing 2/3: [rewrite: sh env | grep RO_ENV] -> compiled rewrite.1 -> installed rewrite.1 Done. -### opam env | grep "RO_ENV" +### opam env | sort | grep "RO_ENV" RO_ENVSET='/a/given/path'; export RO_ENVSET; -RO_ENVSET_STR='something'; export RO_ENVSET_STR; -RO_ENVSET_STR_WS='something/else'; export RO_ENVSET_STR_WS; RO_ENVSET_COL='"s:mething"'; export RO_ENVSET_COL; RO_ENVSET_COL_TARGET='a:/nother/gi;ven/path;a/path/to'; export RO_ENVSET_COL_TARGET; RO_ENVSET_COL_TARGET_QUOTED='"a:/nother/gi;ven/path":a/path/to:"this/i:s/quoted"'; export RO_ENVSET_COL_TARGET_QUOTED; +RO_ENVSET_STR='something'; export RO_ENVSET_STR; +RO_ENVSET_STR_WS='something/else'; export RO_ENVSET_STR_WS; ### cat OPAM/rewriting/.opam-switch/environment | grep RO_ENV RO_ENVSET = /a/given/path : target Updated\ by\ package\ rewrite RO_ENVSET_STR = something Updated\ by\ package\ rewrite @@ -686,7 +686,7 @@ setenv: [ [ RAF_ENVSET_DBL += "fir/st" ] [ RAF_ENVSET_DBL += "sec/ond" ] ] -build: [ "sh" "-c" "env | grep RAF_ENV" ] +build: [ "sh" "-c" "env | grep RAF_ENV | sort" ] build-env: [ [ RAF_ENVBUILD_TRUE = "/is/true" ] [ RAF_ENVBUILD_FALSE = "/is/false" ] @@ -719,10 +719,10 @@ The following actions will be performed: - install all-formulae 1 [ERROR] Formula can't be completely resolved : RAF_ENVBUILD_UNRES ":" true | ";" true. Using default ':' 'target'. [ERROR] Formula can't be completely resolved : RAF_ENVBUILD_UNRES ("host" true | "target-quoted" true). Using default ':' 'target'. +Processing 2/3: [all-formulae: sh env | grep RAF_ENV | sort] ++ sh "-c" "env | grep RAF_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/all-formulae.1) [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ("host" true | "target-quoted" true). Using default ':' 'target'. [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ":" true | ";" true. Using default ':' 'target'. -Processing 2/3: [all-formulae: sh env | grep RAF_ENV] -+ sh "-c" "env | grep RAF_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/all-formulae.1) - RAF_ENVBUILD_ATOM=/is/atom - RAF_ENVBUILD_FALSE=/is/false - RAF_ENVBUILD_RES=/is/resolved @@ -739,13 +739,13 @@ Processing 2/3: [all-formulae: sh env | grep RAF_ENV] [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ":" true | ";" true. Using default ':' 'target'. [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ("host" true | "target-quoted" true). Using default ':' 'target'. Done. -### opam env | grep "RAF_ENV" -RAF_ENVSET_TRUE='/is/true'; export RAF_ENVSET_TRUE; -RAF_ENVSET_FALSE='/is/false'; export RAF_ENVSET_FALSE; +### opam env | sort | grep "RAF_ENV" RAF_ENVSET_ATOM='/is/atom'; export RAF_ENVSET_ATOM; -RAF_ENVSET_UNRES='/is/unresolved'; export RAF_ENVSET_UNRES; -RAF_ENVSET_RES='/is/resolved'; export RAF_ENVSET_RES; RAF_ENVSET_DBL='sec/ond:fir/st'; export RAF_ENVSET_DBL; +RAF_ENVSET_FALSE='/is/false'; export RAF_ENVSET_FALSE; +RAF_ENVSET_RES='/is/resolved'; export RAF_ENVSET_RES; +RAF_ENVSET_TRUE='/is/true'; export RAF_ENVSET_TRUE; +RAF_ENVSET_UNRES='/is/unresolved'; export RAF_ENVSET_UNRES; ### cat OPAM/rewriting/.opam-switch/environment | grep RAF_ENV RAF_ENVSET_TRUE = /is/true Updated\ by\ package\ all-formulae RAF_ENVSET_FALSE = /is/false norewrite Updated\ by\ package\ all-formulae diff --git a/tests/reftests/env.win32.test b/tests/reftests/env.win32.test index 44e4fc06ee1..539a10c408d 100644 --- a/tests/reftests/env.win32.test +++ b/tests/reftests/env.win32.test @@ -1,6 +1,60 @@ N0REP0 ### : setenv & build env rewriting : ### opam switch create rewriting --empty +### : Test for #4861 +### +opam-version: "2.0" +setenv: [ + [ PATH += "XXX:\\" ] + [ PATH += "C:\\Devel\\bin1;C:\\Devel\\bin2;\"C:\\Devel\\bin3;\";C:\\Devel\\bin4;ZZZ:\\" ] +] +x-env-path-rewrite: [ + [ PATH false ] +] +### opam install multipath -yv +The following actions will be performed: +=== install 1 package + - install multipath 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed multipath.1 +Done. +### : The 'set "P' -> 'set P' rewrite masks differences between whether Path +### : already contains a directory which needs escaping (e.g. building with +### : MSVC) +### opam env --shell=cmd | grep "PATH" | 'XXX:.*' -> '' | 'set "P' -> 'set P' +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' +### : Test for #5838 +### opam env | grep MANPATH +MANPATH=':"${BASEDIR}/OPAM/rewriting/man"'; export MANPATH; +### opam exec -- opam env --revert | grep MANPATH +MANPATH=''; export MANPATH; +### : Tests forward and backslash rewriting on revert +### : This sequence of updates is what presently happens with the compiler +### +opam-version: "2.0" +setenv: [ + [ CAML_LD_LIBRARY_PATH = "C:\\Devel\\Roots\\regression\\default\\lib/stublibs" ] + [ CAML_LD_LIBRARY_PATH = "C:/Devel/Roots/regression/default/lib/ocaml/stublibs;C:/Devel/Roots/regression/default/lib/ocaml" ] + [ CAML_LD_LIBRARY_PATH += "C:\\Devel\\Roots\\regression\\default\\lib/stublibs" ] +] +x-env-path-rewrite: [ + [ CAML_LD_LIBRARY_PATH ";" "target" ] +] +### opam install mixed-updates +The following actions will be performed: +=== install 1 package + - install mixed-updates 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed mixed-updates.1 +Done. +### opam env | grep "CAML_LD_LIBRARY_PATH" +CAML_LD_LIBRARY_PATH='C:\Devel\Roots\regression\default\lib\stublibs;C:\Devel\Roots\regression\default\lib\ocaml\stublibs;C:\Devel\Roots\regression\default\lib\ocaml'; export CAML_LD_LIBRARY_PATH; +### opam exec -- opam env --revert | grep "CAML_LD_LIBRARY_PATH" +CAML_LD_LIBRARY_PATH=''; export CAML_LD_LIBRARY_PATH; ### ::::::::::::::::::: ### : Column & target : ### ::::::::::::::::::: @@ -18,13 +72,14 @@ setenv: [ [ RCT_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RCT_ENVBUILD = "/a/given/path" ] [ RCT_ENVBUILD_STR = "something" ] [ RCT_ENVBUILD_WITH_COL = "s:mething" ] [ RCT_ENVBUILD_ADD += "/a/given/path" ] [ RCT_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RCT_ENV" ] +build: [ "sh" "-c" "env | grep RCT_ENV | sort" ] x-env-path-rewrite: [ [ RCT_ENVSET ":" "target" ] [ RCT_ENVSET_STR ":" "target" ] @@ -44,8 +99,8 @@ The following actions will be performed: - install col-target 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [col-target: sh env | grep RCT_ENV] -+ sh "-c" "env | grep RCT_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-target.1) +Processing 2/3: [col-target: sh env | grep RCT_ENV | sort] ++ sh "-c" "env | grep RCT_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-target.1) - RCT_ENVBUILD=\a\given\path - RCT_ENVBUILD_ADD=\a\given\path:a/path/to - RCT_ENVBUILD_ADD_WITH_COL=a:\nother\gi;ven\path:/a/path/to:"t:/his/is/quoted" @@ -56,12 +111,12 @@ Processing 2/3: [col-target: sh env | grep RCT_ENV] -> compiled col-target.1 -> installed col-target.1 Done. -### opam env | grep "RCT_ENV" +### opam env | sort | grep "RCT_ENV" RCT_ENVSET='\a\given\path'; export RCT_ENVSET; -RCT_ENVSET_STR='something'; export RCT_ENVSET_STR; -RCT_ENVSET_WITH_COL='s:mething'; export RCT_ENVSET_WITH_COL; RCT_ENVSET_ADD='\a\given\path:a/path/to'; export RCT_ENVSET_ADD; RCT_ENVSET_ADD_WITH_COL='a:\nother\gi;ven\path:/a/path/to:"t:/his/is/quoted"'; export RCT_ENVSET_ADD_WITH_COL; +RCT_ENVSET_STR='something'; export RCT_ENVSET_STR; +RCT_ENVSET_WITH_COL='s:mething'; export RCT_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RCT_ENV RCT_ENVSET = /a/given/path : target Updated\ by\ package\ col-target RCT_ENVSET_STR = something : target Updated\ by\ package\ col-target @@ -85,13 +140,14 @@ setenv: [ [ RCTQ_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RCTQ_ENVBUILD = "/a/given/path" ] [ RCTQ_ENVBUILD_STR = "something" ] [ RCTQ_ENVBUILD_WITH_COL = "s:mething" ] [ RCTQ_ENVBUILD_ADD += "/a/given/path" ] [ RCTQ_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RCTQ_ENV" ] +build: [ "sh" "-c" "env | grep RCTQ_ENV | sort" ] x-env-path-rewrite: [ [ RCTQ_ENVSET ":" "target-quoted" ] [ RCTQ_ENVSET_STR ":" "target-quoted" ] @@ -111,8 +167,8 @@ The following actions will be performed: - install col-target-quoted 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [col-target-quoted: sh env | grep RCTQ_ENV] -+ sh "-c" "env | grep RCTQ_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-target-quoted.1) +Processing 2/3: [col-target-quoted: sh env | grep RCTQ_ENV | sort] ++ sh "-c" "env | grep RCTQ_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-target-quoted.1) - RCTQ_ENVBUILD=\a\given\path - RCTQ_ENVBUILD_ADD=\a\given\path:a/path/to - RCTQ_ENVBUILD_ADD_WITH_COL="a:\nother\gi;ven\path":/a/path/to:"t:/his/is/quoted" @@ -123,12 +179,12 @@ Processing 2/3: [col-target-quoted: sh env | grep RCTQ_ENV] -> compiled col-target-quoted.1 -> installed col-target-quoted.1 Done. -### opam env | grep "RCTQ_ENV" +### opam env | sort | grep "RCTQ_ENV" RCTQ_ENVSET='\a\given\path'; export RCTQ_ENVSET; -RCTQ_ENVSET_STR='something'; export RCTQ_ENVSET_STR; -RCTQ_ENVSET_WITH_COL='"s:mething"'; export RCTQ_ENVSET_WITH_COL; RCTQ_ENVSET_ADD='\a\given\path:a/path/to'; export RCTQ_ENVSET_ADD; RCTQ_ENVSET_ADD_WITH_COL='"a:\nother\gi;ven\path":/a/path/to:"t:/his/is/quoted"'; export RCTQ_ENVSET_ADD_WITH_COL; +RCTQ_ENVSET_STR='something'; export RCTQ_ENVSET_STR; +RCTQ_ENVSET_WITH_COL='"s:mething"'; export RCTQ_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RCTQ_ENV RCTQ_ENVSET = /a/given/path : target-quoted Updated\ by\ package\ col-target-quoted RCTQ_ENVSET_STR = something : target-quoted Updated\ by\ package\ col-target-quoted @@ -152,13 +208,14 @@ setenv: [ [ RCH_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RCH_ENVBUILD = "/a/given/path" ] [ RCH_ENVBUILD_STR = "something" ] [ RCH_ENVBUILD_WITH_COL = "s:mething" ] [ RCH_ENVBUILD_ADD += "/a/given/path" ] [ RCH_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RCH_ENV" ] +build: [ "sh" "-c" "env | grep RCH_ENV | sort" ] x-env-path-rewrite: [ [ RCH_ENVSET ":" "host" ] [ RCH_ENVSET_STR ":" "host" ] @@ -178,8 +235,8 @@ The following actions will be performed: - install col-host 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [col-host: sh env | grep RCH_ENV] -+ sh "-c" "env | grep RCH_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-host.1) +Processing 2/3: [col-host: sh env | grep RCH_ENV | sort] ++ sh "-c" "env | grep RCH_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-host.1) - RCH_ENVBUILD=/a/given/path - RCH_ENVBUILD_ADD=/a/given/path:a/path/to - RCH_ENVBUILD_ADD_WITH_COL=/cygdrive/a/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted" @@ -190,12 +247,12 @@ Processing 2/3: [col-host: sh env | grep RCH_ENV] -> compiled col-host.1 -> installed col-host.1 Done. -### opam env | grep "RCH_ENV" +### opam env | sort | grep "RCH_ENV" RCH_ENVSET='/a/given/path'; export RCH_ENVSET; -RCH_ENVSET_STR='something'; export RCH_ENVSET_STR; -RCH_ENVSET_WITH_COL='s:mething'; export RCH_ENVSET_WITH_COL; RCH_ENVSET_ADD='/a/given/path:a/path/to'; export RCH_ENVSET_ADD; RCH_ENVSET_ADD_WITH_COL='/cygdrive/a/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted"'; export RCH_ENVSET_ADD_WITH_COL; +RCH_ENVSET_STR='something'; export RCH_ENVSET_STR; +RCH_ENVSET_WITH_COL='s:mething'; export RCH_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RCH_ENV RCH_ENVSET = /a/given/path : host Updated\ by\ package\ col-host RCH_ENVSET_STR = something : host Updated\ by\ package\ col-host @@ -219,13 +276,14 @@ setenv: [ [ RCHQ_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RCHQ_ENVBUILD = "/a/given/path" ] [ RCHQ_ENVBUILD_STR = "something" ] [ RCHQ_ENVBUILD_WITH_COL = "s:mething" ] [ RCHQ_ENVBUILD_ADD += "/a/given/path" ] [ RCHQ_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RCHQ_ENV" ] +build: [ "sh" "-c" "env | grep RCHQ_ENV | sort" ] x-env-path-rewrite: [ [ RCHQ_ENVSET ":" "host-quoted" ] [ RCHQ_ENVSET_STR ":" "host-quoted" ] @@ -245,8 +303,8 @@ The following actions will be performed: - install col-host-quoted 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [col-host-quoted: sh env | grep RCHQ_ENV] -+ sh "-c" "env | grep RCHQ_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-host-quoted.1) +Processing 2/3: [col-host-quoted: sh env | grep RCHQ_ENV | sort] ++ sh "-c" "env | grep RCHQ_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/col-host-quoted.1) - RCHQ_ENVBUILD=/a/given/path - RCHQ_ENVBUILD_ADD=/a/given/path:a/path/to - RCHQ_ENVBUILD_ADD_WITH_COL=/cygdrive/a/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted" @@ -257,12 +315,12 @@ Processing 2/3: [col-host-quoted: sh env | grep RCHQ_ENV] -> compiled col-host-quoted.1 -> installed col-host-quoted.1 Done. -### opam env | grep "RCHQ_ENV" +### opam env | sort | grep "RCHQ_ENV" RCHQ_ENVSET='/a/given/path'; export RCHQ_ENVSET; -RCHQ_ENVSET_STR='something'; export RCHQ_ENVSET_STR; -RCHQ_ENVSET_WITH_COL='"s:mething"'; export RCHQ_ENVSET_WITH_COL; RCHQ_ENVSET_ADD='/a/given/path:a/path/to'; export RCHQ_ENVSET_ADD; RCHQ_ENVSET_ADD_WITH_COL='/cygdrive/a/nother/gi;ven/path:/a/path/to:"t:/his/is/quoted"'; export RCHQ_ENVSET_ADD_WITH_COL; +RCHQ_ENVSET_STR='something'; export RCHQ_ENVSET_STR; +RCHQ_ENVSET_WITH_COL='"s:mething"'; export RCHQ_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RCHQ_ENV RCHQ_ENVSET = /a/given/path : host-quoted Updated\ by\ package\ col-host-quoted RCHQ_ENVSET_STR = something : host-quoted Updated\ by\ package\ col-host-quoted @@ -286,13 +344,14 @@ setenv: [ [ RST_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RST_ENVBUILD = "/a/given/path" ] [ RST_ENVBUILD_STR = "something" ] [ RST_ENVBUILD_WITH_COL = "s:mething" ] [ RST_ENVBUILD_ADD += "/a/given/path" ] [ RST_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RST_ENV" ] +build: [ "sh" "-c" "env | grep RST_ENV | sort" ] x-env-path-rewrite: [ [ RST_ENVSET ";" "target" ] [ RST_ENVSET_STR ";" "target" ] @@ -312,8 +371,8 @@ The following actions will be performed: - install semicol-target 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [semicol-target: sh env | grep RST_ENV] -+ sh "-c" "env | grep RST_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-target.1) +Processing 2/3: [semicol-target: sh env | grep RST_ENV | sort] ++ sh "-c" "env | grep RST_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-target.1) - RST_ENVBUILD=\a\given\path - RST_ENVBUILD_ADD=\a\given\path;a/path/to - RST_ENVBUILD_ADD_WITH_COL=a:\nother\gi;ven\path;/a/path/to;"t:/his/is/quoted" @@ -324,12 +383,12 @@ Processing 2/3: [semicol-target: sh env | grep RST_ENV] -> compiled semicol-target.1 -> installed semicol-target.1 Done. -### opam env | grep "RST_ENV" +### opam env | sort | grep "RST_ENV" RST_ENVSET='\a\given\path'; export RST_ENVSET; -RST_ENVSET_STR='something'; export RST_ENVSET_STR; -RST_ENVSET_WITH_COL='s:mething'; export RST_ENVSET_WITH_COL; RST_ENVSET_ADD='\a\given\path;a/path/to'; export RST_ENVSET_ADD; RST_ENVSET_ADD_WITH_COL='a:\nother\gi;ven\path;/a/path/to;"t:/his/is/quoted"'; export RST_ENVSET_ADD_WITH_COL; +RST_ENVSET_STR='something'; export RST_ENVSET_STR; +RST_ENVSET_WITH_COL='s:mething'; export RST_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RST_ENV RST_ENVSET = /a/given/path ; target Updated\ by\ package\ semicol-target RST_ENVSET_STR = something ; target Updated\ by\ package\ semicol-target @@ -353,13 +412,14 @@ setenv: [ [ RSTQ_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RSTQ_ENVBUILD = "/a/given/path" ] [ RSTQ_ENVBUILD_STR = "something" ] [ RSTQ_ENVBUILD_WITH_COL = "s:mething" ] [ RSTQ_ENVBUILD_ADD += "/a/given/path" ] [ RSTQ_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RSTQ_ENV" ] +build: [ "sh" "-c" "env | grep RSTQ_ENV | sort" ] x-env-path-rewrite: [ [ RSTQ_ENVSET ";" "target-quoted" ] [ RSTQ_ENVSET_STR ";" "target-quoted" ] @@ -379,8 +439,8 @@ The following actions will be performed: - install semicol-target-quoted 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [semicol-target-quoted: sh env | grep RSTQ_ENV] -+ sh "-c" "env | grep RSTQ_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-target-quoted.1) +Processing 2/3: [semicol-target-quoted: sh env | grep RSTQ_ENV | sort] ++ sh "-c" "env | grep RSTQ_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-target-quoted.1) - RSTQ_ENVBUILD=\a\given\path - RSTQ_ENVBUILD_ADD=\a\given\path;a/path/to - RSTQ_ENVBUILD_ADD_WITH_COL="a:\nother\gi;ven\path";/a/path/to;"t:/his/is/quoted" @@ -391,12 +451,12 @@ Processing 2/3: [semicol-target-quoted: sh env | grep RSTQ_ENV] -> compiled semicol-target-quoted.1 -> installed semicol-target-quoted.1 Done. -### opam env | grep "RSTQ_ENV" +### opam env | sort | grep "RSTQ_ENV" RSTQ_ENVSET='\a\given\path'; export RSTQ_ENVSET; -RSTQ_ENVSET_STR='something'; export RSTQ_ENVSET_STR; -RSTQ_ENVSET_WITH_COL='s:mething'; export RSTQ_ENVSET_WITH_COL; RSTQ_ENVSET_ADD='\a\given\path;a/path/to'; export RSTQ_ENVSET_ADD; RSTQ_ENVSET_ADD_WITH_COL='"a:\nother\gi;ven\path";/a/path/to;"t:/his/is/quoted"'; export RSTQ_ENVSET_ADD_WITH_COL; +RSTQ_ENVSET_STR='something'; export RSTQ_ENVSET_STR; +RSTQ_ENVSET_WITH_COL='s:mething'; export RSTQ_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RSTQ_ENV RSTQ_ENVSET = /a/given/path ; target-quoted Updated\ by\ package\ semicol-target-quoted RSTQ_ENVSET_STR = something ; target-quoted Updated\ by\ package\ semicol-target-quoted @@ -420,13 +480,14 @@ setenv: [ [ RSH_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RSH_ENVBUILD = "/a/given/path" ] [ RSH_ENVBUILD_STR = "something" ] [ RSH_ENVBUILD_WITH_COL = "s:mething" ] [ RSH_ENVBUILD_ADD += "/a/given/path" ] [ RSH_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RSH_ENV" ] +build: [ "sh" "-c" "env | grep RSH_ENV | sort" ] x-env-path-rewrite: [ [ RSH_ENVSET ";" "host" ] [ RSH_ENVSET_STR ";" "host" ] @@ -446,8 +507,8 @@ The following actions will be performed: - install semicol-host 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [semicol-host: sh env | grep RSH_ENV] -+ sh "-c" "env | grep RSH_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-host.1) +Processing 2/3: [semicol-host: sh env | grep RSH_ENV | sort] ++ sh "-c" "env | grep RSH_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-host.1) - RSH_ENVBUILD=/a/given/path - RSH_ENVBUILD_ADD=/a/given/path;a/path/to - RSH_ENVBUILD_ADD_WITH_COL=/cygdrive/a/nother/gi;ven/path;/a/path/to;"t:/his/is/quoted" @@ -458,12 +519,12 @@ Processing 2/3: [semicol-host: sh env | grep RSH_ENV] -> compiled semicol-host.1 -> installed semicol-host.1 Done. -### opam env | grep "RSH_ENV" +### opam env | sort | grep "RSH_ENV" RSH_ENVSET='/a/given/path'; export RSH_ENVSET; -RSH_ENVSET_STR='something'; export RSH_ENVSET_STR; -RSH_ENVSET_WITH_COL='s:mething'; export RSH_ENVSET_WITH_COL; RSH_ENVSET_ADD='/a/given/path;a/path/to'; export RSH_ENVSET_ADD; RSH_ENVSET_ADD_WITH_COL='/cygdrive/a/nother/gi;ven/path;/a/path/to;"t:/his/is/quoted"'; export RSH_ENVSET_ADD_WITH_COL; +RSH_ENVSET_STR='something'; export RSH_ENVSET_STR; +RSH_ENVSET_WITH_COL='s:mething'; export RSH_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RSH_ENV RSH_ENVSET = /a/given/path ; host Updated\ by\ package\ semicol-host RSH_ENVSET_STR = something ; host Updated\ by\ package\ semicol-host @@ -487,13 +548,14 @@ setenv: [ [ RSHQ_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RSHQ_ENVBUILD = "/a/given/path" ] [ RSHQ_ENVBUILD_STR = "something" ] [ RSHQ_ENVBUILD_WITH_COL = "s:mething" ] [ RSHQ_ENVBUILD_ADD += "/a/given/path" ] [ RSHQ_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RSHQ_ENV" ] +build: [ "sh" "-c" "env | grep RSHQ_ENV | sort" ] x-env-path-rewrite: [ [ RSHQ_ENVSET ";" "host-quoted" ] [ RSHQ_ENVSET_STR ";" "host-quoted" ] @@ -513,8 +575,8 @@ The following actions will be performed: - install semicol-host-quoted 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [semicol-host-quoted: sh env | grep RSHQ_ENV] -+ sh "-c" "env | grep RSHQ_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-host-quoted.1) +Processing 2/3: [semicol-host-quoted: sh env | grep RSHQ_ENV | sort] ++ sh "-c" "env | grep RSHQ_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/semicol-host-quoted.1) - RSHQ_ENVBUILD=/a/given/path - RSHQ_ENVBUILD_ADD=/a/given/path;a/path/to - RSHQ_ENVBUILD_ADD_WITH_COL="/cygdrive/a/nother/gi;ven/path";/a/path/to;"t:/his/is/quoted" @@ -525,12 +587,12 @@ Processing 2/3: [semicol-host-quoted: sh env | grep RSHQ_ENV] -> compiled semicol-host-quoted.1 -> installed semicol-host-quoted.1 Done. -### opam env | grep "RSHQ_ENV" +### opam env | sort | grep "RSHQ_ENV" RSHQ_ENVSET='/a/given/path'; export RSHQ_ENVSET; -RSHQ_ENVSET_STR='something'; export RSHQ_ENVSET_STR; -RSHQ_ENVSET_WITH_COL='s:mething'; export RSHQ_ENVSET_WITH_COL; RSHQ_ENVSET_ADD='/a/given/path;a/path/to'; export RSHQ_ENVSET_ADD; RSHQ_ENVSET_ADD_WITH_COL='"/cygdrive/a/nother/gi;ven/path";/a/path/to;"t:/his/is/quoted"'; export RSHQ_ENVSET_ADD_WITH_COL; +RSHQ_ENVSET_STR='something'; export RSHQ_ENVSET_STR; +RSHQ_ENVSET_WITH_COL='s:mething'; export RSHQ_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RSHQ_ENV RSHQ_ENVSET = /a/given/path ; host-quoted Updated\ by\ package\ semicol-host-quoted RSHQ_ENVSET_STR = something ; host-quoted Updated\ by\ package\ semicol-host-quoted @@ -554,19 +616,21 @@ setenv: [ [ RF_ENVSET_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RF_ENVBUILD = "/a/given/path" ] [ RF_ENVBUILD_STR = "something" ] [ RF_ENVBUILD_WITH_COL = "s:mething" ] [ RF_ENVBUILD_ADD += "/a/given/path" ] [ RF_ENVBUILD_ADD_WITH_COL += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RF_ENV" ] +build: [ "sh" "-c" "env | grep RF_ENV | sort" ] x-env-path-rewrite: [ [ RF_ENVSET false ] [ RF_ENVSET_STR false ] [ RF_ENVSET_WITH_COL false ] [ RF_ENVSET_ADD false ] [ RF_ENVSET_ADD_WITH_COL false ] + [ PATH false ] [ RF_ENVBUILD false ] [ RF_ENVBUILD_STR false ] @@ -580,8 +644,8 @@ The following actions will be performed: - install false 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [false: sh env | grep RF_ENV] -+ sh "-c" "env | grep RF_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/false.1) +Processing 2/3: [false: sh env | grep RF_ENV | sort] ++ sh "-c" "env | grep RF_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/false.1) - RF_ENVBUILD=/a/given/path - RF_ENVBUILD_ADD=/a/given/path;a/path/to - RF_ENVBUILD_ADD_WITH_COL=a:/nother/gi;ven/path;/a/path/to:"t:/his/is/quoted" @@ -592,12 +656,12 @@ Processing 2/3: [false: sh env | grep RF_ENV] -> compiled false.1 -> installed false.1 Done. -### opam env | grep "RF_ENV" +### opam env | sort | grep "RF_ENV" RF_ENVSET='/a/given/path'; export RF_ENVSET; -RF_ENVSET_STR='something'; export RF_ENVSET_STR; -RF_ENVSET_WITH_COL='s:mething'; export RF_ENVSET_WITH_COL; RF_ENVSET_ADD='/a/given/path;a/path/to'; export RF_ENVSET_ADD; RF_ENVSET_ADD_WITH_COL='a:/nother/gi;ven/path;/a/path/to:"t:/his/is/quoted"'; export RF_ENVSET_ADD_WITH_COL; +RF_ENVSET_STR='something'; export RF_ENVSET_STR; +RF_ENVSET_WITH_COL='s:mething'; export RF_ENVSET_WITH_COL; ### cat OPAM/rewriting/.opam-switch/environment | grep RF_ENV RF_ENVSET = /a/given/path norewrite Updated\ by\ package\ false RF_ENVSET_STR = something norewrite Updated\ by\ package\ false @@ -623,13 +687,14 @@ setenv: [ [ RO_ENVSET_COL_TARGET_QUOTED += "a:/nother/gi;ven/path" ] ] build-env: [ + [ LC_ALL = "C" ] [ RO_ENVBUILD = "/another/given/path" ] [ RO_ENVBUILD_STR = "something" ] [ RO_ENVBUILD_COL = "s:mething" ] [ RO_ENVBUILD_COL_TARGET += "a:/nother/gi;ven/path" ] [ RO_ENVBUILD_COL_TARGET_QUOTED += "a:/nother/gi;ven/path" ] ] -build: [ "sh" "-c" "env | grep RO_ENV" ] +build: [ "sh" "-c" "env | grep RO_ENV | sort" ] x-env-path-rewrite: [ [ RO_ENVSET ":" "target" ] [ RO_ENVSET_STR_WS false ] @@ -651,8 +716,8 @@ The following actions will be performed: - install rewrite 1 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -Processing 2/3: [rewrite: sh env | grep RO_ENV] -+ sh "-c" "env | grep RO_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/rewrite.1) +Processing 2/3: [rewrite: sh env | grep RO_ENV | sort] ++ sh "-c" "env | grep RO_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/rewrite.1) - RO_ENVBUILD=\another\given\path - RO_ENVBUILD_COL=s:mething - RO_ENVBUILD_COL_TARGET=/cygdrive/a/nother/gi;ven/path;a/path/to @@ -663,14 +728,14 @@ Processing 2/3: [rewrite: sh env | grep RO_ENV] -> compiled rewrite.1 -> installed rewrite.1 Done. -### opam env | grep "RO_ENV" +### opam env | sort | grep "RO_ENV" RO_ENVSET='\a\given\path'; export RO_ENVSET; -RO_ENVSET_STR='something'; export RO_ENVSET_STR; -RO_ENVSET_STR_WS='something/else'; export RO_ENVSET_STR_WS; -RO_ENVSET_STR_WS2='something/else'; export RO_ENVSET_STR_WS2; RO_ENVSET_COL='"s:mething"'; export RO_ENVSET_COL; RO_ENVSET_COL_TARGET='/cygdrive/a/nother/gi;ven/path;a/path/to'; export RO_ENVSET_COL_TARGET; RO_ENVSET_COL_TARGET_QUOTED='/cygdrive/a/nother/gi;ven/path:a/path/to:"this/i:s/quoted"'; export RO_ENVSET_COL_TARGET_QUOTED; +RO_ENVSET_STR='something'; export RO_ENVSET_STR; +RO_ENVSET_STR_WS2='something/else'; export RO_ENVSET_STR_WS2; +RO_ENVSET_STR_WS='something/else'; export RO_ENVSET_STR_WS; ### cat OPAM/rewriting/.opam-switch/environment | grep RO_ENV RO_ENVSET = /a/given/path : target Updated\ by\ package\ rewrite RO_ENVSET_STR = something Updated\ by\ package\ rewrite @@ -693,8 +758,9 @@ setenv: [ [ RAF_ENVSET_DBL += "fir/st" ] [ RAF_ENVSET_DBL += "sec/ond" ] ] -build: [ "sh" "-c" "env | grep RAF_ENV" ] +build: [ "sh" "-c" "env | grep RAF_ENV | sort" ] build-env: [ + [ LC_ALL = "C" ] [ RAF_ENVBUILD_TRUE = "/is/true" ] [ RAF_ENVBUILD_FALSE = "/is/false" ] [ RAF_ENVBUILD_ATOM = "/is/atom" ] @@ -724,21 +790,21 @@ x-env-path-rewrite: [ The following actions will be performed: === install 1 package - install all-formulae 1 -[ERROR] Formula can't be completely resolved : RAF_ENVBUILD_UNRES ":" true | ";" true. Using default ';' 'target'. -[ERROR] Formula can't be completely resolved : RAF_ENVBUILD_UNRES ("host" true | "target-quoted" true). Using default ';' 'target'. -[ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ("host" true | "target-quoted" true). Using default ';' 'target'. -[ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ":" true | ";" true. Using default ';' 'target'. -Processing 2/3: [all-formulae: sh env | grep RAF_ENV] -+ sh "-c" "env | grep RAF_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/all-formulae.1) + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +Processing 2/3: [all-formulae: sh env | grep RAF_ENV | sort] ++ sh "-c" "env | grep RAF_ENV | sort" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/all-formulae.1) - RAF_ENVBUILD_ATOM=\is\atom - RAF_ENVBUILD_FALSE=/is/false - RAF_ENVBUILD_RES=/is/resolved - RAF_ENVBUILD_TRUE=/is/true - RAF_ENVBUILD_UNRES=/is/unresolved -> compiled all-formulae.1 - -<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed all-formulae.1 +[ERROR] Formula can't be completely resolved : RAF_ENVBUILD_UNRES ":" true | ";" true. Using default ';' 'target'. +[ERROR] Formula can't be completely resolved : RAF_ENVBUILD_UNRES ("host" true | "target-quoted" true). Using default ';' 'target'. +[ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ("host" true | "target-quoted" true). Using default ';' 'target'. +[ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ":" true | ";" true. Using default ';' 'target'. [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ":" true | ";" true. Using default ';' 'target'. [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ("host" true | "target-quoted" true). Using default ';' 'target'. [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ":" true | ";" true. Using default ';' 'target'. @@ -746,13 +812,13 @@ Processing 2/3: [all-formulae: sh env | grep RAF_ENV] [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ":" true | ";" true. Using default ';' 'target'. [ERROR] Formula can't be completely resolved : RAF_ENVSET_UNRES ("host" true | "target-quoted" true). Using default ';' 'target'. Done. -### opam env | grep "RAF_ENV" -RAF_ENVSET_TRUE='/is/true'; export RAF_ENVSET_TRUE; -RAF_ENVSET_FALSE='/is/false'; export RAF_ENVSET_FALSE; +### opam env | sort | grep "RAF_ENV" RAF_ENVSET_ATOM='\is\atom'; export RAF_ENVSET_ATOM; -RAF_ENVSET_UNRES='/is/unresolved'; export RAF_ENVSET_UNRES; -RAF_ENVSET_RES='/is/resolved'; export RAF_ENVSET_RES; RAF_ENVSET_DBL='sec/ond;fir/st'; export RAF_ENVSET_DBL; +RAF_ENVSET_FALSE='/is/false'; export RAF_ENVSET_FALSE; +RAF_ENVSET_RES='/is/resolved'; export RAF_ENVSET_RES; +RAF_ENVSET_TRUE='/is/true'; export RAF_ENVSET_TRUE; +RAF_ENVSET_UNRES='/is/unresolved'; export RAF_ENVSET_UNRES; ### cat OPAM/rewriting/.opam-switch/environment | grep RAF_ENV RAF_ENVSET_TRUE = /is/true Updated\ by\ package\ all-formulae RAF_ENVSET_FALSE = /is/false norewrite Updated\ by\ package\ all-formulae diff --git a/tests/reftests/run.ml b/tests/reftests/run.ml index 06ddcb87ca8..46a3d31dfa9 100644 --- a/tests/reftests/run.ml +++ b/tests/reftests/run.ml @@ -192,7 +192,7 @@ let filters_of_var = Sed x) let command - ?(allowed_codes = [0]) ?(vars=[]) ?(silent=false) ?(filter=[]) + ?(allowed_codes = [0]) ?(vars=[]) ?(silent=false) ?(filter=[]) ?(sort=false) cmd args = let env = Array.of_list @@ @@ -225,23 +225,30 @@ let command Unix.stdin stdout stdout in Unix.close stdout; - let out_buf = Buffer.create 273 in - let rec filter_output ?(first=true) ic = + let rec filter_output out_buf ic = match input_line ic with | s -> - let s = str_replace_path ~escape:`Unescape OpamSystem.back_to_forward filter s in - if s = "\\c" then filter_output ~first ic + let s = + str_replace_path ~escape:`Unescape OpamSystem.back_to_forward filter s + in + if s = "\\c" then filter_output out_buf ic else - (if not first then Buffer.add_char out_buf '\n'; - Buffer.add_string out_buf s; - if not silent then print_endline s; - filter_output ~first:false ic) - | exception End_of_file -> () + (let out_buf = s::out_buf in + if not silent && not sort then + print_endline s; + filter_output out_buf ic) + | exception End_of_file -> out_buf in - filter_output ic; + let out_buf = filter_output [] ic in let ret = waitpid pid in close_in ic; - let out = Buffer.contents out_buf in + let out = + if sort then List.sort String.compare out_buf + else List.rev out_buf + in + if not silent && sort then + List.iter print_endline out; + let out = String.concat "\n" out in if not (List.mem ret allowed_codes) then raise (Command_failure (ret, String.concat " " (cmd :: args), out)) else @@ -309,7 +316,8 @@ type command = args: string list; (* still escaped *) filter: (Re.t * filt_sort) list; output: string option; - unordered: bool; } + unordered: bool; + sort: bool;} | Export of (string * [`eq | `pluseq | `eqplus] * string) list | Comment of string @@ -420,17 +428,21 @@ module Parse = struct failwith (Printf.sprintf "Bad POSIX regexp: %s" re) in let rec get_args_rewr acc = function - | [] -> List.rev acc, false, [], None + | [] -> List.rev acc, false, false, [], None | ("|"|">$") :: _ as rewr -> - let rec get_rewr (unordered, acc) = function + let rec get_rewr (unordered, sort, acc) = function | "|" :: re :: "->" :: str :: r -> - get_rewr (unordered, (posix_re re, Sed (get_str str)) :: acc) r + get_rewr (unordered, sort, (posix_re re, Sed (get_str str)) :: acc) r | "|" :: "grep" :: "-v" :: re :: r -> - get_rewr (unordered, (posix_re re, GrepV) :: acc) r + get_rewr (unordered, sort, (posix_re re, GrepV) :: acc) r | "|" :: "grep" :: re :: r -> - get_rewr (unordered, (posix_re re, Grep) :: acc) r + get_rewr (unordered, sort, (posix_re re, Grep) :: acc) r + | "|" :: "sort" :: r -> + if acc <> [] then + Printf.printf "Warning: sort should appear _before_ any filters\n%!"; + get_rewr (unordered, true, acc) r | "|" :: "unordered" :: r -> - get_rewr (true, acc) r + get_rewr (true, sort, acc) r | "|" :: "sed-cmd" :: cmd :: r -> let sandbox = (* Sandbox prefix @@ -487,22 +499,22 @@ module Parse = struct ] in let re = alt @@ sandbox :: unix_prefix @ win_prefix in let str = Printf.sprintf "%s " cmd in - get_rewr (unordered, (re, Sed str) :: acc) r + get_rewr (unordered, sort, (re, Sed str) :: acc) r | ">$" :: output :: [] -> - unordered, List.rev acc, Some (get_str output) + unordered, sort, List.rev acc, Some (get_str output) | [] -> - unordered, List.rev acc, None + unordered, sort, List.rev acc, None | r -> Printf.printf "Bad rewrite %S, expecting '| RE -> STR' or '>$ VAR'\n%!" (String.concat " " r); - unordered, List.rev acc, None + unordered, sort, List.rev acc, None in - let unordered, rewr, out = get_rewr (false, []) rewr in - List.rev acc, unordered, rewr, out + let unordered, sort, rewr, out = get_rewr (false, false, []) rewr in + List.rev acc, unordered, sort, rewr, out | arg :: r -> get_args_rewr (arg :: acc) r in - let args, unordered, rewr, output = get_args_rewr [] args in + let args, unordered, sort, rewr, output = get_args_rewr [] args in match cmd with | Some "opam-cat" -> Cat { files = args; filter = rewr; } @@ -531,6 +543,7 @@ module Parse = struct filter = rewr; output; unordered; + sort; } | None -> Export varbinds @@ -572,7 +585,7 @@ let common_filters ?opam dir = | None -> [] | Some opam -> [ str opam.as_seen_in_opam, Sed "${OPAM}" ]) -let run_cmd ~opam ~dir ?(vars=[]) ?(filter=[]) ?(silent=false) cmd args = +let run_cmd ~opam ~dir ?(vars=[]) ?(filter=[]) ?(silent=false) ?(sort=false) cmd args = let filter = filter @ common_filters ~opam dir in let var_filters = filters_of_var vars in let cmd = if cmd = "opam" then opam.as_called else cmd in @@ -587,7 +600,7 @@ let run_cmd ~opam ~dir ?(vars=[]) ?(filter=[]) ?(silent=false) cmd args = Parse.get_str expanded) args in - try command ~vars ~filter ~silent cmd args, None + try command ~vars ~filter ~silent ~sort cmd args, None with Command_failure (n,_, out) -> out, Some n let write_file ~path ~contents = @@ -843,10 +856,10 @@ let run_test ?(vars=[]) ~opam t = print_file ~filters:(filter @ common_filters ~opam dir @ json_filters) to_string files; vars - | Run {env; cmd; args; filter; output; unordered} -> + | Run {env; cmd; args; filter; output; unordered; sort} -> let silent = output <> None || unordered in let r, errcode = - run_cmd ~opam ~dir ~vars:(vars @ env) ~filter ~silent cmd args + run_cmd ~opam ~dir ~vars:(vars @ env) ~filter ~silent ~sort cmd args in (if unordered then (* print lines from Result, but respecting order from Expect *)