diff --git a/src/posix.c b/src/posix.c index 9d923c80..a245e972 100644 --- a/src/posix.c +++ b/src/posix.c @@ -135,6 +135,15 @@ getenv_ (SCM s) ///((name . "getenv")) return p ? MAKE_STRING (cstring_to_list (p)) : cell_f; } +SCM +setenv_ (SCM s, SCM v) ///((name . "setenv")) +{ + char buf[1024]; + strcpy (buf, string_to_cstring (s)); + setenv (buf, string_to_cstring (v), 1); + return cell_unspecified; +} + SCM access_p (SCM file_name, SCM mode) { diff --git a/tests/base.test b/tests/base.test index ebc524d2..c3a20d87 100755 --- a/tests/base.test +++ b/tests/base.test @@ -116,4 +116,11 @@ exit $? (pass-if-not "#" (char? (integer->char -1)))) +(pass-if-equal "setenv, getenv" + "bar" + (begin + (setenv "foo" "bar") + (getenv "bar") + (getenv "foo"))) + (result 'report)