tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
1
Task/Environment-variables/0DESCRIPTION
Normal file
1
Task/Environment-variables/0DESCRIPTION
Normal 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.
|
||||
5
Task/Environment-variables/1META.yaml
Normal file
5
Task/Environment-variables/1META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Environment variables
|
||||
- Initialization
|
||||
note: Programming environment operations
|
||||
|
|
@ -0,0 +1 @@
|
|||
print((getenv("HOME"), new line))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$ awk 'BEGIN{print "HOME:"ENVIRON["HOME"],"USER:"ENVIRON["USER"]}'
|
||||
HOME:/home/suchrich USER:SuchRich
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$ awk -v h=$HOME -v u=$USER 'BEGIN{print "HOME:"h,"USER:"u}'
|
||||
HOME:/home/suchrich USER:SuchRich
|
||||
|
|
@ -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;
|
||||
11
Task/Environment-variables/Ada/environment-variables-2.ada
Normal file
11
Task/Environment-variables/Ada/environment-variables-2.ada
Normal 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;
|
||||
15
Task/Environment-variables/Ada/environment-variables-3.ada
Normal file
15
Task/Environment-variables/Ada/environment-variables-3.ada
Normal 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;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
EnvGet, OutputVar, Path
|
||||
MsgBox, %OutputVar%
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
x$ = ENVIRON$("path")
|
||||
PRINT x$
|
||||
|
|
@ -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
|
||||
|
|
@ -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%
|
||||
|
|
@ -0,0 +1 @@
|
|||
echo %Foo%
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
set
|
||||
set Foo
|
||||
8
Task/Environment-variables/C++/environment-variables.cpp
Normal file
8
Task/Environment-variables/C++/environment-variables.cpp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
int main()
|
||||
{
|
||||
puts(getenv("HOME"));
|
||||
return 0;
|
||||
}
|
||||
7
Task/Environment-variables/C/environment-variables.c
Normal file
7
Task/Environment-variables/C/environment-variables.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
puts(getenv("HOME"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
(System/getenv "HOME")
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
for var_name in ['PATH', 'HOME', 'LANG', 'USER']
|
||||
console.log var_name, process.env[var_name]
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lispworks:environment-variable "USER")
|
||||
|
|
@ -0,0 +1 @@
|
|||
(sb-ext:posix-getenv "USER")
|
||||
|
|
@ -0,0 +1 @@
|
|||
(ccl:getenv "USER")
|
||||
|
|
@ -0,0 +1 @@
|
|||
(getenv "HOME")
|
||||
5
Task/Environment-variables/D/environment-variables-1.d
Normal file
5
Task/Environment-variables/D/environment-variables-1.d
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import std.stdio, std.process;
|
||||
|
||||
void main() {
|
||||
auto home = getenv("HOME");
|
||||
}
|
||||
5
Task/Environment-variables/D/environment-variables-2.d
Normal file
5
Task/Environment-variables/D/environment-variables-2.d
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import tango.sys.Environment;
|
||||
|
||||
void main() {
|
||||
auto home = Environment("HOME");
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
program EnvironmentVariable;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses SysUtils;
|
||||
|
||||
begin
|
||||
WriteLn('Temp = ' + GetEnvironmentVariable('TEMP'));
|
||||
end.
|
||||
1
Task/Environment-variables/E/environment-variables.e
Normal file
1
Task/Environment-variables/E/environment-variables.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
<unsafe:java.lang.System>.getenv("HOME")
|
||||
13
Task/Environment-variables/Eiffel/environment-variables.e
Normal file
13
Task/Environment-variables/Eiffel/environment-variables.e
Normal 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
|
||||
|
|
@ -0,0 +1 @@
|
|||
(getenv "HOME")
|
||||
|
|
@ -0,0 +1 @@
|
|||
puts(1,getenv("PATH"))
|
||||
|
|
@ -0,0 +1 @@
|
|||
"HOME" os-env print
|
||||
|
|
@ -0,0 +1 @@
|
|||
s" HOME" getenv type
|
||||
15
Task/Environment-variables/Fortran/environment-variables.f
Normal file
15
Task/Environment-variables/Fortran/environment-variables.f
Normal 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
|
||||
10
Task/Environment-variables/Go/environment-variables-1.go
Normal file
10
Task/Environment-variables/Go/environment-variables-1.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(os.Getenv("SHELL"))
|
||||
}
|
||||
19
Task/Environment-variables/Go/environment-variables-2.go
Normal file
19
Task/Environment-variables/Go/environment-variables-2.go
Normal 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")
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
System.getenv().each { property, value -> println "$property = $value"}
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
CHARACTER string*255
|
||||
|
||||
string = "PATH="
|
||||
SYSTEM(GEteNV = string)
|
||||
|
|
@ -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
|
||||
1
Task/Environment-variables/J/environment-variables.j
Normal file
1
Task/Environment-variables/J/environment-variables.j
Normal file
|
|
@ -0,0 +1 @@
|
|||
2!:5'HOME'
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
System.getenv("HOME") // get env var
|
||||
System.getenv() // get the entire environment as a Map of keys to values
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
var shell = new ActiveXObject("WScript.Shell");
|
||||
var env = shell.Environment("PROCESS");
|
||||
WScript.echo('SYSTEMROOT=' + env.item('SYSTEMROOT'));
|
||||
1
Task/Environment-variables/Joy/environment-variables.joy
Normal file
1
Task/Environment-variables/Joy/environment-variables.joy
Normal file
|
|
@ -0,0 +1 @@
|
|||
"HOME" getenv.
|
||||
1
Task/Environment-variables/K/environment-variables.k
Normal file
1
Task/Environment-variables/K/environment-variables.k
Normal file
|
|
@ -0,0 +1 @@
|
|||
_getenv "HOME"
|
||||
8
Task/Environment-variables/LSL/environment-variables.lsl
Normal file
8
Task/Environment-variables/LSL/environment-variables.lsl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
default {
|
||||
state_entry() {
|
||||
llOwnerSay("llGetTimestamp()="+(string)llGetTimestamp());
|
||||
llOwnerSay("llGetEnergy()="+(string)llGetEnergy());
|
||||
llOwnerSay("llGetFreeMemory()="+(string)llGetFreeMemory());
|
||||
llOwnerSay("llGetMemoryLimit()="+(string)llGetMemoryLimit());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
print StartupDir$
|
||||
print DefaultDir$
|
||||
|
|
@ -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
|
||||
1
Task/Environment-variables/Lua/environment-variables.lua
Normal file
1
Task/Environment-variables/Lua/environment-variables.lua
Normal file
|
|
@ -0,0 +1 @@
|
|||
print( os.getenv( "PATH" ) )
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
getenv('HOME')
|
||||
getenv('PATH')
|
||||
getenv('USER')
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Set X=$ZF(-1,"show logical")
|
||||
Set X=$ZF(-1,"show symbol")
|
||||
|
|
@ -0,0 +1 @@
|
|||
Environment["PATH"]
|
||||
|
|
@ -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)
|
||||
).
|
||||
|
|
@ -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.
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
> (env "SHELL")
|
||||
"/bin/zsh"
|
||||
> (env "TERM")
|
||||
"xterm"
|
||||
|
|
@ -0,0 +1 @@
|
|||
Sys.getenv "HOME"
|
||||
|
|
@ -0,0 +1 @@
|
|||
[[[NSProcessInfo processInfo] environment] objectForKey:@"HOME"]
|
||||
1
Task/Environment-variables/Oz/environment-variables.oz
Normal file
1
Task/Environment-variables/Oz/environment-variables.oz
Normal file
|
|
@ -0,0 +1 @@
|
|||
{System.showInfo "This is where Mozart is installed: "#{OS.getEnv 'OZHOME'}}
|
||||
|
|
@ -0,0 +1 @@
|
|||
getenv("HOME")
|
||||
|
|
@ -0,0 +1 @@
|
|||
externstr("echo $HOME")
|
||||
|
|
@ -0,0 +1 @@
|
|||
extern("echo \"\\\"$HOME\\\"\"")
|
||||
|
|
@ -0,0 +1 @@
|
|||
echo "\"$HOME\""
|
||||
|
|
@ -0,0 +1 @@
|
|||
extern("echo Pi")
|
||||
1
Task/Environment-variables/PHP/environment-variables.php
Normal file
1
Task/Environment-variables/PHP/environment-variables.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
$_ENV['HOME']
|
||||
|
|
@ -0,0 +1 @@
|
|||
say %*ENV<HOME>;
|
||||
1
Task/Environment-variables/Perl/environment-variables.pl
Normal file
1
Task/Environment-variables/Perl/environment-variables.pl
Normal file
|
|
@ -0,0 +1 @@
|
|||
print $ENV{HOME}, "\n";
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
: (sys "TERM")
|
||||
-> "xterm"
|
||||
|
||||
: (sys "SHELL")
|
||||
-> "/bin/bash"
|
||||
|
|
@ -0,0 +1 @@
|
|||
$Env:Path
|
||||
|
|
@ -0,0 +1 @@
|
|||
Get-ChildItem Env:
|
||||
|
|
@ -0,0 +1 @@
|
|||
GetEnvironmentVariable("Name")
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import os
|
||||
os.environ['HOME']
|
||||
1
Task/Environment-variables/R/environment-variables.r
Normal file
1
Task/Environment-variables/R/environment-variables.r
Normal file
|
|
@ -0,0 +1 @@
|
|||
Sys.getenv("PATH")
|
||||
|
|
@ -0,0 +1 @@
|
|||
print get-env "HOME"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
/*REXX program shows how to get an environmental variable under Windows*/
|
||||
|
||||
x=value('TEMP',,'SYSTEM')
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
/*REXX program shows how to get an environmental variable under Windows*/
|
||||
|
||||
x=value('TEMP',,'ENVIRONMENT')
|
||||
|
|
@ -0,0 +1 @@
|
|||
x=getenv("PATH") /* Get the contents of the path environment variable */
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
#lang racket
|
||||
(getenv "HOME")
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
here "HOME" getEnv
|
||||
here puts
|
||||
1
Task/Environment-variables/Ruby/environment-variables.rb
Normal file
1
Task/Environment-variables/Ruby/environment-variables.rb
Normal file
|
|
@ -0,0 +1 @@
|
|||
ENV['HOME']
|
||||
|
|
@ -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$
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
output = host(4,'PATH')
|
||||
end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
writeln(getenv("HOME"));
|
||||
end func;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Environment variables at: 'PATH'.
|
||||
"==> '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'"
|
||||
|
|
@ -0,0 +1 @@
|
|||
OS.Process.getEnv "HOME"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
@(next :env)
|
||||
@(collect)
|
||||
@VAR=@VAL
|
||||
@(end)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
@(next :env)
|
||||
@(gather)
|
||||
HOME=@home
|
||||
USER=@user
|
||||
PATH=@path
|
||||
@(end)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
@(next :env)
|
||||
@(gather :vars (home user path (shell "/bin/sh")))
|
||||
HOME=@home
|
||||
USER=@user
|
||||
PATH=@path
|
||||
SHELL=@shell
|
||||
@(end)
|
||||
1
Task/Environment-variables/Tcl/environment-variables.tcl
Normal file
1
Task/Environment-variables/Tcl/environment-variables.tcl
Normal file
|
|
@ -0,0 +1 @@
|
|||
$env(HOME)
|
||||
|
|
@ -0,0 +1 @@
|
|||
echo "$HOME"
|
||||
|
|
@ -0,0 +1 @@
|
|||
export VAR
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#import std
|
||||
|
||||
#executable ('parameterized','')
|
||||
|
||||
showenv = <.file$[contents: --<''>]>+ %smP+ ~&n-={'TERM','SHELL','X11BROWSER'}*~+ ~environs
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Get_Environment(10,"PATH")
|
||||
Message(@10)
|
||||
|
|
@ -0,0 +1 @@
|
|||
GE(10,"PATH") M(@10)
|
||||
28
Task/Environment-variables/XPL0/environment-variables.xpl0
Normal file
28
Task/Environment-variables/XPL0/environment-variables.xpl0
Normal 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
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue