| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | ! Copyright (C) 2008 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							|  |  |  | USING: assocs help.markup help.syntax io.streams.string sequences strings ;
 | 
					
						
							|  |  |  | IN: environment | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: (os-envs) | 
					
						
							|  |  |  | { $values | 
					
						
							| 
									
										
										
										
											2011-02-19 14:08:45 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  |      { "seq" sequence } } | 
					
						
							| 
									
										
										
										
											2009-01-30 16:29:28 -05:00
										 |  |  | { $description "Returns a sequence of key/value pairs from the operating system." } | 
					
						
							|  |  |  | { $notes "In most cases, use " { $link os-envs } " instead." } ;
 | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | HELP: (set-os-envs) | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |      { "seq" sequence } } | 
					
						
							| 
									
										
										
										
											2009-01-30 16:29:28 -05:00
										 |  |  | { $description "Low-level word for replacing the current set of environment variables." } | 
					
						
							|  |  |  | { $notes "In most cases, use " { $link set-os-envs } " instead." } ;
 | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 02:18:24 -04:00
										 |  |  | HELP: os-env | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | { $values { "key" string } { "value" string } } | 
					
						
							|  |  |  | { $description "Looks up the value of a shell environment variable." } | 
					
						
							|  |  |  | { $examples | 
					
						
							|  |  |  |     "This is an operating system-specific feature. On Unix, you can do:" | 
					
						
							| 
									
										
										
										
											2011-02-19 14:08:45 -05:00
										 |  |  |     { $unchecked-example | 
					
						
							|  |  |  |         "USING: environment io ;" | 
					
						
							|  |  |  |         "\"USER\" os-env print" | 
					
						
							|  |  |  |         "jane" | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-19 21:45:53 -04:00
										 |  |  | HELP: change-os-env | 
					
						
							|  |  |  | { $values { "key" string } { "quot" { $quotation "( old -- new )" } } } | 
					
						
							|  |  |  | { $description "Applies a quotation to change the value stored in an environment variable." } | 
					
						
							|  |  |  | { $examples | 
					
						
							|  |  |  |     "This is an operating system-specific feature. On Unix, you can do:" | 
					
						
							|  |  |  |     { $unchecked-example | 
					
						
							|  |  |  |         "USING: environment io ;" | 
					
						
							|  |  |  |         "\"USER\" os-env print" | 
					
						
							|  |  |  |         "\"USER\" [ \"-doe\" append ] change-os-env" | 
					
						
							|  |  |  |         "\"USER\" os-env print" | 
					
						
							|  |  |  |         "jane\njane-doe" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $side-effects "key" } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | HELP: os-envs | 
					
						
							|  |  |  | { $values { "assoc" "an association mapping strings to strings" } } | 
					
						
							|  |  |  | { $description "Outputs the current set of environment variables." } | 
					
						
							|  |  |  | { $notes | 
					
						
							|  |  |  |     "Names and values of environment variables are operating system-specific." | 
					
						
							|  |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: set-os-envs | 
					
						
							|  |  |  | { $values { "assoc" "an association mapping strings to strings" } } | 
					
						
							|  |  |  | { $description "Replaces the current set of environment variables." } | 
					
						
							|  |  |  | { $notes | 
					
						
							|  |  |  |     "Names and values of environment variables are operating system-specific. Windows NT allows values up to 32766 characters in length." | 
					
						
							|  |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 02:18:24 -04:00
										 |  |  | HELP: set-os-env | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | { $values { "value" string } { "key" string } } | 
					
						
							|  |  |  | { $description "Set an environment variable." } | 
					
						
							|  |  |  | { $notes | 
					
						
							|  |  |  |     "Names and values of environment variables are operating system-specific." | 
					
						
							|  |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 02:18:24 -04:00
										 |  |  | HELP: unset-os-env | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | { $values { "key" string } } | 
					
						
							|  |  |  | { $description "Unset an environment variable." } | 
					
						
							|  |  |  | { $notes | 
					
						
							|  |  |  |     "Names and values of environment variables are operating system-specific." | 
					
						
							|  |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-19 21:45:53 -04:00
										 |  |  | { os-env os-envs set-os-env unset-os-env set-os-envs change-os-env } related-words | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ARTICLE: "environment" "Environment variables" | 
					
						
							|  |  |  | "The " { $vocab-link "environment" } " vocabulary interfaces to the platform-dependent mechanism for setting environment variables." $nl | 
					
						
							|  |  |  | "Reading environment variables:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections | 
					
						
							|  |  |  |     os-env | 
					
						
							|  |  |  |     os-envs | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | "Writing environment variables:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections | 
					
						
							|  |  |  |     set-os-env | 
					
						
							|  |  |  |     unset-os-env | 
					
						
							|  |  |  |     set-os-envs | 
					
						
							| 
									
										
										
										
											2012-06-19 21:45:53 -04:00
										 |  |  |     change-os-env | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | } ;
 | 
					
						
							| 
									
										
										
										
											2008-10-18 22:20:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ABOUT: "environment" |