Skip to content

Commit

Permalink
idris_support: fix environ for macOS (#3324)
Browse files Browse the repository at this point in the history
* idris_support: fix environ for macOS

* Add test that touches the new implementation of environ

---------

Co-authored-by: Sergey Fedorov <[email protected]>
Co-authored-by: Mathew Polzin <[email protected]>
  • Loading branch information
3 people authored Jul 3, 2024
1 parent efce152 commit 1931509
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions support/c/idris_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ char **_argv;
extern char **_environ;
#include "windows/win_utils.h"
#define environ _environ
#elif defined(__APPLE__)
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
#else
extern char **environ;
#endif
Expand Down
8 changes: 8 additions & 0 deletions tests/base/system_get_environment/Test.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import System

main : IO ()
main = do
env <- getEnvironment
-- it better be non-empty because we set a variable before starting this test
printLn $ null env

1 change: 1 addition & 0 deletions tests/base/system_get_environment/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
False
4 changes: 4 additions & 0 deletions tests/base/system_get_environment/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
. ../../testutils.sh

idris2 --cg chez -o test Test.idr
HELLO=hi ./build/exec/test

0 comments on commit 1931509

Please sign in to comment.