This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,7 @@
(lang dune 1.5)
(env
(_
(env-vars
(VARIABLE value1)
(VARIABLE value2))))

View file

@ -0,0 +1,8 @@
When a variable is repeated, an error message is displayed:
$ dune build
File "dune-workspace", lines 6-7, characters 3-41:
6 | (VARIABLE value1)
7 | (VARIABLE value2))))
Error: Variable VARIABLE is specified several times
[1]

View file

@ -0,0 +1,2 @@
(executable
(name printenv))

View file

@ -0,0 +1,15 @@
(lang dune 1.5)
(env
(_
(env-vars
(VARIABLE_FROM_WORKSPACE value1)
(VARIABLE_FROM_BOTH from_workspace))))
(context
(default
(env
(_
(env-vars
(VARIABLE_FROM_CONTEXT value2)
(VARIABLE_FROM_BOTH from_context))))))

View file

@ -0,0 +1,5 @@
let var_to_string k = try Sys.getenv k with Not_found -> "(unset)"
let print_var k = Printf.printf "%s=%s\n" k (var_to_string k)
let () = print_var Sys.argv.(1)

View file

@ -0,0 +1,17 @@
Environment variables defined in (env) are set during execution.
They can be set from the workspace:
$ dune exec ./printenv.exe VARIABLE_FROM_WORKSPACE
VARIABLE_FROM_WORKSPACE=value1
From a (context) stanza in the workspace:
$ dune exec ./printenv.exe VARIABLE_FROM_CONTEXT
VARIABLE_FROM_CONTEXT=value2
When a variable is set from both a context and a global one, the context one is
used.
$ dune exec ./printenv.exe VARIABLE_FROM_BOTH
VARIABLE_FROM_BOTH=from_workspace