mes: Add setenv.

* src/posix.c (setenv_): New function.
* tests/base.test ("setenv, getenv"): Test it.
This commit is contained in:
Jan Nieuwenhuizen 2018-04-07 09:34:02 +02:00
parent bd82d5988d
commit 6932d83d82
2 changed files with 16 additions and 0 deletions

View file

@ -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)
{

View file

@ -116,4 +116,11 @@ exit $?
(pass-if-not "#<eof>"
(char? (integer->char -1))))
(pass-if-equal "setenv, getenv"
"bar"
(begin
(setenv "foo" "bar")
(getenv "bar")
(getenv "foo")))
(result 'report)