environment: adding a combinator to set and unset and os-env.
parent
6be25de125
commit
15ab7fe82a
|
@ -35,3 +35,9 @@ os unix? [
|
||||||
|
|
||||||
! Issue #794, setting something to ``f`` is a memory protection fault on mac
|
! Issue #794, setting something to ``f`` is a memory protection fault on mac
|
||||||
[ ] [ f "dummy-env-variable-for-factor-test" set-os-env ] unit-test
|
[ ] [ f "dummy-env-variable-for-factor-test" set-os-env ] unit-test
|
||||||
|
|
||||||
|
{ f "value" f } [
|
||||||
|
"factor-test-key" os-env
|
||||||
|
"value" "factor-test-key" [ "factor-test-key" os-env ] with-os-env
|
||||||
|
"factor-test-key" os-env
|
||||||
|
] unit-test
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: assocs combinators init kernel sequences splitting
|
USING: assocs combinators continuations init kernel sequences
|
||||||
system vocabs vocabs.loader ;
|
splitting system vocabs vocabs.loader ;
|
||||||
IN: environment
|
IN: environment
|
||||||
|
|
||||||
HOOK: os-env os ( key -- value )
|
HOOK: os-env os ( key -- value )
|
||||||
|
@ -25,6 +25,10 @@ HOOK: set-os-envs-pointer os ( malloc -- )
|
||||||
: set-os-envs ( assoc -- )
|
: set-os-envs ( assoc -- )
|
||||||
[ "=" glue ] { } assoc>map (set-os-envs) ;
|
[ "=" glue ] { } assoc>map (set-os-envs) ;
|
||||||
|
|
||||||
|
: with-os-env ( value key quot -- )
|
||||||
|
over [ [ [ set-os-env ] 2curry ] [ compose ] bi* ] dip
|
||||||
|
[ os-env ] keep [ set-os-env ] 2curry [ ] cleanup ; inline
|
||||||
|
|
||||||
{
|
{
|
||||||
{ [ os unix? ] [ "environment.unix" require ] }
|
{ [ os unix? ] [ "environment.unix" require ] }
|
||||||
{ [ os windows? ] [ "environment.windows" require ] }
|
{ [ os windows? ] [ "environment.windows" require ] }
|
||||||
|
|
Loading…
Reference in New Issue