summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/c/urweb.c5
-rw-r--r--tests/getenv.ur3
-rw-r--r--tests/getenv.urp3
3 files changed, 10 insertions, 1 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 9bf72ce1..5ac5aa55 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -3669,7 +3669,10 @@ uw_unit uw_Basis_setHeader(uw_context ctx, uw_Basis_string name, uw_Basis_string
}
uw_Basis_string uw_Basis_getenv(uw_context ctx, uw_Basis_string name) {
- return ctx->get_env(ctx->get_env_data, name);
+ if (ctx->get_env)
+ return ctx->get_env(ctx->get_env_data, name);
+ else
+ return NULL;
}
uw_Basis_string uw_unnull(uw_Basis_string s) {
diff --git a/tests/getenv.ur b/tests/getenv.ur
new file mode 100644
index 00000000..42f48096
--- /dev/null
+++ b/tests/getenv.ur
@@ -0,0 +1,3 @@
+task initialize = fn _ =>
+ v <- getenv (blessEnvVar "USER");
+ return {}
diff --git a/tests/getenv.urp b/tests/getenv.urp
new file mode 100644
index 00000000..7acc7c70
--- /dev/null
+++ b/tests/getenv.urp
@@ -0,0 +1,3 @@
+allow env USER
+
+getenv