os: Implement getenv().

pull/20/merge
Paul Sokolovsky 2015-02-07 00:29:46 +02:00
rodzic f3dd9abcda
commit e8813f3f03
2 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,3 @@
import os
print(os.getenv("HOME", "def"))

Wyświetl plik

@ -32,6 +32,7 @@ _exit_ = libc.func("v", "_exit", "i")
getpid_ = libc.func("i", "getpid", "")
waitpid_ = libc.func("i", "waitpid", "ipi")
system_ = libc.func("i", "system", "s")
getenv_ = libc.func("s", "getenv", "P")
R_OK = const(4)
W_OK = const(2)
@ -204,6 +205,12 @@ def system(command):
check_error(r)
return r
def getenv(var, default=None):
var = getenv_(var)
if var is None:
return default
return var
def fsencode(s):
if type(s) is bytes:
return s