From efda6dad2f7f2178a03bbedc88b1ee3f463a73d3 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 20 Nov 2024 08:36:50 -0800 Subject: [PATCH] environment: adding os-env? word --- basis/environment/environment-docs.factor | 6 +++++- basis/environment/environment.factor | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/basis/environment/environment-docs.factor b/basis/environment/environment-docs.factor index 71d4b4f06f7..1b4d316973d 100644 --- a/basis/environment/environment-docs.factor +++ b/basis/environment/environment-docs.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Doug Coleman. ! See https://factorcode.org/license.txt for BSD license. -USING: assocs help.markup help.syntax io.streams.string +USING: assocs help.markup help.syntax io.streams.string kernel libc sequences strings ; IN: environment @@ -29,6 +29,10 @@ HELP: os-env } } ; +HELP: os-env? +{ $values { "key" string } { "?" boolean } } +{ $description "Returns " { $link t } " if the environment variable is set to a non-empty value." } ; + HELP: change-os-env { $values { "key" string } { "quot" { $quotation ( old -- new ) } } } { $description "Applies a quotation to change the value stored in an environment variable." } diff --git a/basis/environment/environment.factor b/basis/environment/environment.factor index ffd3eb441d4..a4093ad609a 100644 --- a/basis/environment/environment.factor +++ b/basis/environment/environment.factor @@ -16,6 +16,8 @@ HOOK: (set-os-envs) os ( seq -- ) HOOK: set-os-envs-pointer os ( malloc -- ) +: os-env? ( key -- ? ) os-env empty? not ; + : change-os-env ( key quot -- ) [ [ os-env ] keep ] dip dip set-os-env ; inline