1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs help.markup help.syntax io.streams.string sequences strings ;
10 { $description "Returns a sequence of key/value pairs from the operating system." }
11 { $notes "In most cases, use " { $link os-envs } " instead." } ;
16 { $description "Low-level word for replacing the current set of environment variables." }
17 { $notes "In most cases, use " { $link set-os-envs } " instead." } ;
20 HELP: os-env ( key -- value )
21 { $values { "key" string } { "value" string } }
22 { $description "Looks up the value of a shell environment variable." }
24 "This is an operating system-specific feature. On Unix, you can do:"
25 { $unchecked-example "\"USER\" os-env print" "jane" }
29 { $values { "assoc" "an association mapping strings to strings" } }
30 { $description "Outputs the current set of environment variables." }
32 "Names and values of environment variables are operating system-specific."
36 { $values { "assoc" "an association mapping strings to strings" } }
37 { $description "Replaces the current set of environment variables." }
39 "Names and values of environment variables are operating system-specific. Windows NT allows values up to 32766 characters in length."
42 HELP: set-os-env ( value key -- )
43 { $values { "value" string } { "key" string } }
44 { $description "Set an environment variable." }
46 "Names and values of environment variables are operating system-specific."
49 HELP: unset-os-env ( key -- )
50 { $values { "key" string } }
51 { $description "Unset an environment variable." }
53 "Names and values of environment variables are operating system-specific."
56 { os-env os-envs set-os-env unset-os-env set-os-envs } related-words
59 ARTICLE: "environment" "Environment variables"
60 "The " { $vocab-link "environment" } " vocabulary interfaces to the platform-dependent mechanism for setting environment variables." $nl
61 "Windows CE has no concept of environment variables, so these words are undefined on that platform." $nl
62 "Reading environment variables:"
63 { $subsection os-env }
64 { $subsection os-envs }
65 "Writing environment variables:"
66 { $subsection set-os-env }
67 { $subsection unset-os-env }
68 { $subsection set-os-envs } ;