tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1 @@
Show how to get one of your process's [[wp:Environment variable|environment variables]]. The available variables vary by system; some of the common ones available on Unix include PATH, HOME, USER.

View file

@ -0,0 +1,5 @@
---
category:
- Environment variables
- Initialization
note: Programming environment operations

View file

@ -0,0 +1 @@
print((getenv("HOME"), new line))

View file

@ -0,0 +1,2 @@
$ awk 'BEGIN{print "HOME:"ENVIRON["HOME"],"USER:"ENVIRON["USER"]}'
HOME:/home/suchrich USER:SuchRich

View file

@ -0,0 +1,2 @@
$ awk -v h=$HOME -v u=$USER 'BEGIN{print "HOME:"h,"USER:"u}'
HOME:/home/suchrich USER:SuchRich

View file

@ -0,0 +1,7 @@
with Ada.Environment_Variables; use Ada.Environment_Variables;
with Ada.Text_Io; use Ada.Text_Io;
procedure Print_Path is
begin
Put_Line("Path : " & Value("PATH"));
end Print_Path;

View file

@ -0,0 +1,11 @@
with Ada.Environment_Variables; use Ada.Environment_Variables;
with Ada.Text_Io; use Ada.Text_Io;
procedure Env_Vars is
procedure Print_Vars(Name, Value : in String) is
begin
Put_Line(Name & " : " & Value);
end Print_Vars;
begin
Iterate(Print_Vars'access);
end Env_Vars;

View file

@ -0,0 +1,15 @@
with Ada.Wide_Wide_Text_IO;
with League.Application;
with League.Strings;
procedure Main is
function "+"
(Item : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
begin
Ada.Wide_Wide_Text_IO.Put_Line
(League.Application.Environment.Value (+"HOME").To_Wide_Wide_String);
end Main;

View file

@ -0,0 +1,2 @@
EnvGet, OutputVar, Path
MsgBox, %OutputVar%

View file

@ -0,0 +1,2 @@
x$ = ENVIRON$("path")
PRINT x$

View file

@ -0,0 +1,3 @@
10 PRINT "The border colour is "; PEEK (23624): REM bordcr
20 PRINT "The ramtop address is "; PEEK (23730) + 256 * PEEK (23731): REM ramtop
30 POKE 23609,50: REM set keyboard pip to 50

View file

@ -0,0 +1,10 @@
PRINT FNenvironment("PATH")
PRINT FNenvironment("USERNAME")
END
DEF FNenvironment(envar$)
LOCAL buffer%, size%
SYS "GetEnvironmentVariable", envar$, 0, 0 TO size%
DIM buffer% LOCAL size%
SYS "GetEnvironmentVariable", envar$, buffer%, size%+1
= $$buffer%

View file

@ -0,0 +1 @@
echo %Foo%

View file

@ -0,0 +1,2 @@
set
set Foo

View file

@ -0,0 +1,8 @@
#include <cstdlib>
#include <cstdio>
int main()
{
puts(getenv("HOME"));
return 0;
}

View file

@ -0,0 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
int main() {
puts(getenv("HOME"));
return 0;
}

View file

@ -0,0 +1 @@
(System/getenv "HOME")

View file

@ -0,0 +1,2 @@
for var_name in ['PATH', 'HOME', 'LANG', 'USER']
console.log var_name, process.env[var_name]

View file

@ -0,0 +1 @@
(lispworks:environment-variable "USER")

View file

@ -0,0 +1 @@
(sb-ext:posix-getenv "USER")

View file

@ -0,0 +1 @@
(ccl:getenv "USER")

View file

@ -0,0 +1 @@
(getenv "HOME")

View file

@ -0,0 +1,5 @@
import std.stdio, std.process;
void main() {
auto home = getenv("HOME");
}

View file

@ -0,0 +1,5 @@
import tango.sys.Environment;
void main() {
auto home = Environment("HOME");
}

View file

@ -0,0 +1,9 @@
program EnvironmentVariable;
{$APPTYPE CONSOLE}
uses SysUtils;
begin
WriteLn('Temp = ' + GetEnvironmentVariable('TEMP'));
end.

View file

@ -0,0 +1 @@
<unsafe:java.lang.System>.getenv("HOME")

View file

@ -0,0 +1,13 @@
class
APPLICATION
inherit
EXECUTION_ENVIRONMENT
create
make
feature {NONE} -- Initialization
make
-- Retrieve and print value for environment variable `USERNAME'.
do
print (get ("USERNAME"))
end
end

View file

@ -0,0 +1 @@
(getenv "HOME")

View file

@ -0,0 +1 @@
puts(1,getenv("PATH"))

View file

@ -0,0 +1 @@
"HOME" os-env print

View file

@ -0,0 +1 @@
s" HOME" getenv type

View file

@ -0,0 +1,15 @@
program show_home
implicit none
character(len=32) :: home_val ! The string value of the variable HOME
integer :: home_len ! The actual length of the value
integer :: stat ! The status of the value:
! 0 = ok
! 1 = variable does not exist
! -1 = variable is not long enought to hold the result
call get_environment_variable('HOME', home_val, home_len, stat)
if (stat == 0) then
write(*,'(a)') 'HOME = '//trim(home_val)
else
write(*,'(a)') 'No HOME to go to!'
end if
end program show_home

View file

@ -0,0 +1,10 @@
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println(os.Getenv("SHELL"))
}

View file

@ -0,0 +1,19 @@
package main
import (
"fmt"
"os"
"strings"
)
func main() {
s := "SHELL"
se := s + "="
for _, v := range os.Environ() {
if strings.HasPrefix(v, se) {
fmt.Println(s, "has value", v[len(se):])
return
}
}
fmt.Println(s, "not found")
}

View file

@ -0,0 +1 @@
System.getenv().each { property, value -> println "$property = $value"}

View file

@ -0,0 +1,3 @@
import System.Environment
main = do getEnv "HOME" >>= print -- get env var
getEnvironment >>= print -- get the entire environment as a list of (key, value) pairs

View file

@ -0,0 +1,4 @@
CHARACTER string*255
string = "PATH="
SYSTEM(GEteNV = string)

View file

@ -0,0 +1,7 @@
procedure main(arglist)
if *envars = 0 then envars := ["HOME", "TRACE", "BLKSIZE","STRSIZE","COEXPSIZE","MSTKSIZE", "IPATH","LPATH","NOERRBUF"]
every v := !sort(envars) do
write(v," = ",image(getenv(v))|"* not set *")
end

View file

@ -0,0 +1 @@
2!:5'HOME'

View file

@ -0,0 +1,2 @@
System.getenv("HOME") // get env var
System.getenv() // get the entire environment as a Map of keys to values

View file

@ -0,0 +1,3 @@
var shell = new ActiveXObject("WScript.Shell");
var env = shell.Environment("PROCESS");
WScript.echo('SYSTEMROOT=' + env.item('SYSTEMROOT'));

View file

@ -0,0 +1 @@
"HOME" getenv.

View file

@ -0,0 +1 @@
_getenv "HOME"

View file

@ -0,0 +1,8 @@
default {
state_entry() {
llOwnerSay("llGetTimestamp()="+(string)llGetTimestamp());
llOwnerSay("llGetEnergy()="+(string)llGetEnergy());
llOwnerSay("llGetFreeMemory()="+(string)llGetFreeMemory());
llOwnerSay("llGetMemoryLimit()="+(string)llGetMemoryLimit());
}
}

View file

@ -0,0 +1,2 @@
print StartupDir$
print DefaultDir$

View file

@ -0,0 +1,29 @@
print GetEnvironmentVariable$("USERNAME")
print GetEnvironmentVariable$("USERPROFILE") ' equivalent to UNIX HOME variable
print GetEnvironmentVariable$("PATH")
end
function GetEnvironmentVariable$(lpName$)
'get the value of an environment variable
nSize = 1024
[Retry]
lpBuffer$ = space$(nSize)
calldll #kernel32, "GetEnvironmentVariableA", _
lpName$ as ptr, _
lpBuffer$ as ptr, _
nSize as ulong, _
result as ulong
select case
' buffer too small
case result > nSize
nSize = result
goto [Retry]
' variable found
case result > 0
GetEnvironmentVariable$ = left$(lpBuffer$, result)
end select
end function

View file

@ -0,0 +1 @@
print( os.getenv( "PATH" ) )

View file

@ -0,0 +1,3 @@
getenv('HOME')
getenv('PATH')
getenv('USER')

View file

@ -0,0 +1,2 @@
Set X=$ZF(-1,"show logical")
Set X=$ZF(-1,"show symbol")

View file

@ -0,0 +1 @@
Environment["PATH"]

View file

@ -0,0 +1,18 @@
:- module env_var.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module maybe, string.
main(!IO) :-
io.get_environment_var("HOME", MaybeValue, !IO),
(
MaybeValue = yes(Value),
io.write_string("HOME is " ++ Value ++ "\n", !IO)
;
MaybeValue = no,
io.write_string("environment variable HOME not set\n", !IO)
).

View file

@ -0,0 +1,3 @@
ExpandEnvStrings $0 "%PATH%" ; Retrieve PATH and place it in builtin register 0.
ExpandEnvStrings $1 "%USERPROFILE%" ; Retrieve the user's profile location and place it in builtin register 1.
ExpandEnvStrings $2 "%USERNAME%" ; Retrieve the user's account name and place it in builtin register 2.

View file

@ -0,0 +1,60 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method sysEnvironment(vn = '') public static
if vn.length > 0 then do
envName = vn
envValu = System.getenv(envName)
if envValu = null then envValu = ''
say envName '=' envValu
end
else do
envVars = System.getenv()
key = String
loop key over envVars.keySet()
envName = key
envValu = String envVars.get(key)
say envName '=' envValu
end key
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method sysProperties(vn = '') public static
if vn.length > 0 then do
propName = vn
propValu = System.getProperty(propName)
if propValu = null then propValu = ''
say propName '=' propValu
end
else do
sysProps = System.getProperties()
key = String
loop key over sysProps.keySet()
propName = key
propValu = sysProps.getProperty(key)
say propName '=' propValu
end key
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) public static
parse arg ev pv .
if ev = '' then ev = 'CLASSPATH'
if pv = '' then pv = 'java.class.path'
say '-'.left(80, '-').overlay(' Environment "'ev'" ', 5)
sysEnvironment(ev)
say '-'.left(80, '-').overlay(' Properties "'pv'" ', 5)
sysProperties(pv)
say
say '-'.left(80, '-').overlay(' Environment ', 5)
sysEnvironment()
say '-'.left(80, '-').overlay(' Properties ', 5)
sysProperties()
say
return

View file

@ -0,0 +1,4 @@
> (env "SHELL")
"/bin/zsh"
> (env "TERM")
"xterm"

View file

@ -0,0 +1 @@
Sys.getenv "HOME"

View file

@ -0,0 +1 @@
[[[NSProcessInfo processInfo] environment] objectForKey:@"HOME"]

View file

@ -0,0 +1 @@
{System.showInfo "This is where Mozart is installed: "#{OS.getEnv 'OZHOME'}}

View file

@ -0,0 +1 @@
getenv("HOME")

View file

@ -0,0 +1 @@
externstr("echo $HOME")

View file

@ -0,0 +1 @@
extern("echo \"\\\"$HOME\\\"\"")

View file

@ -0,0 +1 @@
echo "\"$HOME\""

View file

@ -0,0 +1 @@
extern("echo Pi")

View file

@ -0,0 +1 @@
$_ENV['HOME']

View file

@ -0,0 +1 @@
say %*ENV<HOME>;

View file

@ -0,0 +1 @@
print $ENV{HOME}, "\n";

View file

@ -0,0 +1,5 @@
: (sys "TERM")
-> "xterm"
: (sys "SHELL")
-> "/bin/bash"

View file

@ -0,0 +1 @@
$Env:Path

View file

@ -0,0 +1 @@
Get-ChildItem Env:

View file

@ -0,0 +1 @@
GetEnvironmentVariable("Name")

View file

@ -0,0 +1,8 @@
If OpenConsole()
PrintN("Path:"+#CRLF$ + GetEnvironmentVariable("PATH"))
PrintN(#CRLF$+#CRLF$+"NUMBER_OF_PROCESSORS= "+ GetEnvironmentVariable("NUMBER_OF_PROCESSORS"))
PrintN(#CRLF$+#CRLF$+"Press Enter to quit.")
Input()
CloseConsole()
EndIf

View file

@ -0,0 +1,2 @@
import os
os.environ['HOME']

View file

@ -0,0 +1 @@
Sys.getenv("PATH")

View file

@ -0,0 +1 @@
print get-env "HOME"

View file

@ -0,0 +1,3 @@
/*REXX program shows how to get an environmental variable under Windows*/
x=value('TEMP',,'SYSTEM')

View file

@ -0,0 +1,3 @@
/*REXX program shows how to get an environmental variable under Windows*/
x=value('TEMP',,'ENVIRONMENT')

View file

@ -0,0 +1 @@
x=getenv("PATH") /* Get the contents of the path environment variable */

View file

@ -0,0 +1,2 @@
#lang racket
(getenv "HOME")

View file

@ -0,0 +1,2 @@
here "HOME" getEnv
here puts

View file

@ -0,0 +1 @@
ENV['HOME']

View file

@ -0,0 +1,20 @@
' ------- Major environment variables -------------------------------------------
'DefaultDir$ - The folder path where program files are read/written by default
'Platform$ - The operating system on which Run BASIC is being hosted
'UserInfo$ - This is information about the user's web browser
'UrlKeys$ - Contains informational parameters from the URL submitted when the user connected
'UserAddress$ - Contains the IP address of the user
'ProjectsRoot$ - The folder path where Run BASIC keeps programming projects
'ResourcesRoot$ - The folder path where Run BASIC keeps web-servable files
'Err$ - A description of the last runtime error
'Err - A numeric code for the last runtime error (errors that have no code use zero)
'EventKey$ - The id of the object that generated the last user event
'RowIndex - The numeric index of the table or database accessor link that generated the last user event
print "User Info is : ";UserInfo$
print "Platform is : ";Platform$
print "Url Keys is : ";UrlKeys$
print "User Address is: ";UserAddress$
print "Event Key is : ";EventKey$
print "Default Dir is : ";DefaultDir$

View file

@ -0,0 +1,2 @@
output = host(4,'PATH')
end

View file

@ -0,0 +1,6 @@
$ include "seed7_05.s7i";
const proc: main is func
begin
writeln(getenv("HOME"));
end func;

View file

@ -0,0 +1,2 @@
Environment variables at: 'PATH'.
"==> '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'"

View file

@ -0,0 +1 @@
OS.Process.getEnv "HOME"

View file

@ -0,0 +1,4 @@
@(next :env)
@(collect)
@VAR=@VAL
@(end)

View file

@ -0,0 +1,6 @@
@(next :env)
@(gather)
HOME=@home
USER=@user
PATH=@path
@(end)

View file

@ -0,0 +1,7 @@
@(next :env)
@(gather :vars (home user path (shell "/bin/sh")))
HOME=@home
USER=@user
PATH=@path
SHELL=@shell
@(end)

View file

@ -0,0 +1 @@
$env(HOME)

View file

@ -0,0 +1 @@
echo "$HOME"

View file

@ -0,0 +1 @@
export VAR

View file

@ -0,0 +1,5 @@
#import std
#executable ('parameterized','')
showenv = <.file$[contents: --<''>]>+ %smP+ ~&n-={'TERM','SHELL','X11BROWSER'}*~+ ~environs

View file

@ -0,0 +1,2 @@
Get_Environment(10,"PATH")
Message(@10)

View file

@ -0,0 +1 @@
GE(10,"PATH") M(@10)

View file

@ -0,0 +1,28 @@
include c:\cxpl\codes; \intrinsic 'code' declarations
string 0; \use zero-terminated strings
int CpuReg, PspSeg, EnvSeg, I, J, C;
char EnvVar;
[CpuReg:= GetReg; \access CPU registers
PspSeg:= CpuReg(9); \get segment address of our PSP
EnvSeg:= Peek(PspSeg,$2C) + Peek(PspSeg,$2D)<<8;
EnvVar:= "PATH"; \environment variable
I:= 0;
loop [J:= 0;
loop [C:= Peek(EnvSeg,I); I:= I+1;
if C = 0 then quit;
if C = EnvVar(J) then
[J:= J+1;
if J = 4 then
[Text(0, EnvVar); \show env. var.
loop [C:= Peek(EnvSeg,I); \ and rest of
I:= I+1; \ its string
if C = 0 then exit;
ChOut(0, C);
];
];
]
else J:= 5; \line must start with environment variable
];
if Peek(EnvSeg,I) = 0 then quit; \double 0 = env. var. not found
];
]