N0REP0
### : Revert env with variable from a package :
### <pkg:nv.1>
opam-version: "2.0"
setenv: [ NV_VARS += "%{_:doc}%:%{_:share}%" ]
flags: compiler
### opam switch create setenv nv

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["nv"]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed nv.1
Done.
### opam env | grep "NV_VARS" | ';' -> ':'
NV_VARS='${BASEDIR}/OPAM/setenv/doc/nv:${BASEDIR}/OPAM/setenv/share/nv': export NV_VARS:
### opam exec -- opam env --revert | grep "NV_VARS" | ';' -> ':'
NV_VARS='': export NV_VARS:
### NV_VARS=/another/path
### opam env | grep "NV_VARS" | ';' -> ':'
NV_VARS='${BASEDIR}/OPAM/setenv/doc/nv:${BASEDIR}/OPAM/setenv/share/nv:/another/path': export NV_VARS:
### opam exec -- opam env --revert | grep "NV_VARS" | ';' -> ':'
NV_VARS='/another/path': export NV_VARS:
### : package variable available at install stage :
### <pkg:nv.1>
opam-version: "2.0"
setenv: [NV_VARS  = "%{_:nv_config}%"]
flags: compiler
### <pkg:nv.1:nv.config>
opam-version: "2.0"
variables { nv_config: "hej!!" }
### opam switch create conffile nv

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["nv"]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed nv.1
Done.
### opam env | grep NV_VARS
NV_VARS='hej!!'; export NV_VARS;
### : opam env and its revert :
### 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;
### opam exec -- env | grep '^NV_VARS|^OPAM_SWITCH_PREFIX|${OPAM}'
NV_VARS=hej!!
OPAM=${OPAM}
OPAM_SWITCH_PREFIX=${BASEDIR}/OPAM/conffile
### opam exec --no-switch -- env | grep "^NV_VARS|^OPAM_SWITCH_PREFIX|${OPAM}"
NV_VARS=/another/path
OPAM=${OPAM}
### : Buil environment variable expansion :
### <pkg:bde.1.2.3>
opam-version: "2.0"
build: [ "sh" "-c" "echo V$BDE_VERSION > pkg.version" ]
install: [ "cp" "pkg.version" "%{doc}%/pkg.version" ]
build-env: [ BDE_VERSION = "%{version}%" ]
### opam switch create build-env --empty
### opam install bde
The following actions will be performed:
=== install 1 package
  - install bde 1.2.3

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed bde.1.2.3
Done.
### cat $OPAMROOT/build-env/doc/pkg.version
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:
### <pkg:nv.1>
opam-version: "2.0"
setenv: [
  [ NV_VARS  += ""    ]
  [ NV_VARS2 := ""    ]
  [ NV_VARS3 := ""    ]
  [ 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 <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["nv"]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed nv.1
Done.
### opam exec -- env | grep "NV_VARS" | ';' -> ':'
NV_VARS=
NV_VARS3=foo:
NV_VARS4=
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
### NV_VARS4=ignored-value
### opam exec -- env | grep "NV_VARS" | ';' -> ':'
NV_VARS=/another/path
NV_VARS2=/another/different/path
NV_VARS3=foo:/yet/another/different/path
NV_VARS4=
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 :
### <pkg:foo.1>
opam-version: "2.0"
setenv: [ FOO  = "--> I'm here" ]
### opam switch create full-revert --empty
### opam install foo
The following actions will be performed:
=== install 1 package
  - install foo 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed foo.1
Done.
### opam exec -- sh -c "eval $(opam env | tr -d '\\r'); echo $FOO"
--> I'm here
### opam exec -- sh -c "eval $(opam env | tr -d '\\r'); opam remove foo; eval $(opam env | tr -d '\\r'); echo $FOO"
The following actions will be performed:
=== remove 1 package
  - remove foo 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   foo.1
Done.

### opam install foo
The following actions will be performed:
=== install 1 package
  - install foo 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed foo.1
Done.
### opam exec -- sh -c "eval $(opam env | tr -d '\\r'); opam remove foo; opam env; eval $(opam env | tr -d '\\r'); opam env" | grep "FOO"
FOO=''; export FOO;
### : Env hooks :
### <pkg:av.1>
opam-version: "2.0"
setenv: [ A_VAR  = "%{lib}%" ]
### opam switch create switch1 av

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["av"]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed av.1
Done.
### opam switch create switch2 av

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["av"]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed av.1
Done.
### # switch switch
### opam switch switch1
### opam env --readonly --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/OPAM/switch1/.opam-switch/environment in 0.000s
FILE(environment)               Wrote ${BASEDIR}/OPAM/.last-env/env-hash-0 atomically in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/OPAM/switch1/lib': export A_VAR:
### opam env --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/OPAM/switch1/.opam-switch/environment in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/OPAM/switch1/lib': export A_VAR:
### # missing environment file
### rm $OPAMROOT/switch1/.opam-switch/environment
### opam env --readonly --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-env
CONFIG                          Missing environment file, regenerate it
STATE                           LOAD-SWITCH-STATE @ switch1
STATE                           Switch state loaded in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/OPAM/switch1/lib': export A_VAR:
### opam env --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-env
CONFIG                          Missing environment file, regenerate it
STATE                           LOAD-SWITCH-STATE @ switch1
STATE                           Switch state loaded in 0.000s
FILE(environment)               Wrote ${BASEDIR}/OPAM/switch1/.opam-switch/environment atomically in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/OPAM/switch1/lib': export A_VAR:
### # set via OPAMSWITCH
### OPAMSWITCH=switch2 opam env --readonly --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/OPAM/switch2/.opam-switch/environment in 0.000s
FILE(environment)               Wrote ${BASEDIR}/OPAM/.last-env/env-hash-0 atomically in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/OPAM/switch2/lib': export A_VAR:
### OPAMSWITCH=switch2 opam env --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/OPAM/switch2/.opam-switch/environment in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/OPAM/switch2/lib': export A_VAR:
### # entering directory
### mkdir local-sw
### opam switch create ./local-sw av

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["av"]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed av.1
Done.
### sh -c "cd local-sw ; opam env --readonly --debug-level=-3" | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | "\(\\\\\|/\)_opam\(\\\\|/\)lib" -> '/_opam/lib' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/local-sw/_opam/.opam-switch/environment in 0.000s
FILE(environment)               Wrote ${BASEDIR}/OPAM/.last-env/env-hash-0 atomically in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/local-sw/_opam/lib': export A_VAR:
### sh -c "cd local-sw ; opam env --debug-level=-3" | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | "\(\\\\\|/\)_opam\(\\\\|/\)lib" -> '/_opam/lib' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/local-sw/_opam/.opam-switch/environment in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/local-sw/_opam/lib': export A_VAR:
### # moving a switch
### mv local-sw local-sw.new
### opam env --switch ./local-sw.new --readonly --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | "\(\\\\\|/\)_opam\(\\\\|/\)lib" -> '/_opam/lib' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/local-sw.new/_opam/.opam-switch/environment in 0.000s
CONFIG                          Switch has moved from ${BASEDIR}/local-sw/_opam to ${BASEDIR}/local-sw.new/_opam
CONFIG                          Regenerating environment file
STATE                           LOAD-SWITCH-STATE @ ${BASEDIR}/local-sw.new
STATE                           Switch state loaded in 0.000s
FILE(environment)               Wrote ${BASEDIR}/OPAM/.last-env/env-hash-0 atomically in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/local-sw.new/_opam/lib': export A_VAR:
### opam env --switch ./local-sw.new --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | "\(\\\\\|/\)_opam\(\\\\|/\)lib" -> '/_opam/lib' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/local-sw.new/_opam/.opam-switch/environment in 0.000s
CONFIG                          Switch has moved from ${BASEDIR}/local-sw/_opam to ${BASEDIR}/local-sw.new/_opam
CONFIG                          Regenerating environment file
STATE                           LOAD-SWITCH-STATE @ ${BASEDIR}/local-sw.new
STATE                           Switch state loaded in 0.000s
FILE(environment)               Wrote ${BASEDIR}/local-sw.new/_opam/.opam-switch/environment atomically in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/local-sw.new/_opam/lib': export A_VAR:
### opam env --switch ./local-sw.new --debug-level=-3 | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | '[0-9a-f]{32}' -> 'hash' | "\(\\\\\|/\)_opam\(\\\\|/\)lib" -> '/_opam/lib' | ';' -> ':'
CONFIG                          config-env
FILE(environment)               Read ${BASEDIR}/local-sw.new/_opam/.opam-switch/environment in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
A_VAR='${BASEDIR}/local-sw.new/_opam/lib': export A_VAR:
### : opam exec & environment regeneration :
### opam exec --debug-level=-3 -- sh -c "echo $A_VAR" | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | grep -v PROC | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-exec command=sh -c echo $A_VAR
FILE(environment)               Read ${BASEDIR}/OPAM/switch1/.opam-switch/environment in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
### rm $OPAMROOT/switch1/.opam-switch/environment
### opam exec --readonly --debug-level=-3 -- sh -c "echo $A_VAR" | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | grep -v PROC  | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-exec command=sh -c echo $A_VAR
CONFIG                          Missing environment file, regenerate it
STATE                           LOAD-SWITCH-STATE @ switch1
STATE                           Switch state loaded in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
### opam exec --debug-level=-3 -- sh -c "echo $A_VAR" | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | grep -v PROC  | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-exec command=sh -c echo $A_VAR
CONFIG                          Missing environment file, regenerate it
STATE                           LOAD-SWITCH-STATE @ switch1
STATE                           Switch state loaded in 0.000s
FILE(environment)               Wrote ${BASEDIR}/OPAM/switch1/.opam-switch/environment atomically in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
### opam exec --debug-level=-3 -- sh -c "echo $A_VAR" | grep "A_VAR\|FILE\\(environment\\)\|CONFIG\|^STATE" | grep -v PROC | '[0-9a-f]{32}' -> 'hash' | ';' -> ':'
CONFIG                          config-exec command=sh -c echo $A_VAR
FILE(environment)               Read ${BASEDIR}/OPAM/switch1/.opam-switch/environment in 0.000s
FILE(environment)               Read ${BASEDIR}/OPAM/.last-env/env-hash-0 in 0.000s
### : Build environment variables and their overwrite :
### # Note: OPAMROOT is not shown as it is defined in the environment
### #       MANPATH is not kept, it is supposed to have the same behaviour thant PATH
### sh -c "env | sort | uniq" >$ LOCALENV
### <pkg:to-build.2>
opam-version: "2.0"
build: [ "sh" "getenv.sh" "1" ]
### <pkg:to-build.2:getenv.sh>
out=build-env
fromtest="^PATH=\|^MANPATH=\|^LOCALENV=\|^TEMPDIR=\|^TMPDIR=\|^TMP=\|^TEMP=\|^SHLVL=\|^PWD=\|^_="
for v in $LOCALENV; do
  if echo "$v" | grep -q "=" ; then
    fromtest="$fromtest\\|^$(echo "$v" | cut -f 1 -d '=')="
  fi
done
env | sort | uniq | grep -v "'$fromtest'"> "$out"
echo "PATH=$(echo $PATH | cut -f "$1" -d ':')" >> "$out"

echo "doc: [ \"$out\"]" > to-build.install
### opam switch create bd --empty
### opam install to-build
The following actions will be performed:
=== install 1 package
  - install to-build 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed to-build.2
Done.
### cat $OPAMROOT/bd/doc/to-build/build-env
CDPATH=
MAKEFLAGS=
MAKELEVEL=
OPAMCLI=2.0
OPAMSWITCH=bd
OPAM_PACKAGE_NAME=to-build
OPAM_PACKAGE_VERSION=2
OPAM_SWITCH_PREFIX=${BASEDIR}/OPAM/bd
PATH=${BASEDIR}/OPAM/bd/bin
### opam remove to-build
The following actions will be performed:
=== remove 1 package
  - remove to-build 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   to-build.2
Done.
### <pkg:to-build.2>
opam-version: "2.0"
build: [ "sh" "getenv.sh" "1-2" ]
build-env: [
  [ CDPATH = "another-cdpath" ]
  [ MAKEFLAGS = "another-makeflags" ]
  [ MAKELEVEL = "another-makelevel" ]
  [ OPAMCLI="1.0" ]
  [ OPAMROOT="another-root" ]
  [ OPAMSWITCH="another-switch" ]
  [ OPAM_PACKAGE_NAME="another-package" ]
  [ OPAM_PACKAGE_VERSION="another-version" ]
  [ OPAM_SWITCH_PREFIX="another-switch-prefix" ]
  [ PATH+="another-path" ]
]
### opam install to-build
The following actions will be performed:
=== install 1 package
  - install to-build 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed to-build.2
Done.
### cat $OPAMROOT/bd/doc/to-build/build-env
CDPATH=another-cdpath
MAKEFLAGS=another-makeflags
MAKELEVEL=another-makelevel
OPAMCLI=1.0
OPAMSWITCH=bd
OPAM_PACKAGE_NAME=another-package
OPAM_PACKAGE_VERSION=another-version
OPAM_SWITCH_PREFIX=${BASEDIR}/OPAM/bd
PATH=${BASEDIR}/OPAM/bd/bin:another-path
