diff --git a/build/oil-defs/Python-2.7.13/Modules/posixmodule.c/posix_methods.def b/build/oil-defs/Python-2.7.13/Modules/posixmodule.c/posix_methods.def index 80083f70b0..ac62553cf4 100644 --- a/build/oil-defs/Python-2.7.13/Modules/posixmodule.c/posix_methods.def +++ b/build/oil-defs/Python-2.7.13/Modules/posixmodule.c/posix_methods.def @@ -32,6 +32,7 @@ static PyMethodDef posix_methods[] = { {"fdopen", posix_fdopen, METH_VARARGS}, {"isatty", posix_isatty, METH_VARARGS}, {"pipe", posix_pipe, METH_NOARGS}, + {"putenv", posix_putenv, METH_VARARGS}, {"strerror", posix_strerror, METH_VARARGS}, /* job control stuff */ diff --git a/osh/builtin_printf.py b/osh/builtin_printf.py index 8ffa9e76ad..8012046182 100755 --- a/osh/builtin_printf.py +++ b/osh/builtin_printf.py @@ -14,7 +14,6 @@ import sys import time -import os from asdl import runtime from core import error @@ -29,6 +28,8 @@ from osh import string_ops from osh import word_compile +import posix_ as posix + from typing import Dict, List, TYPE_CHECKING, cast if TYPE_CHECKING: @@ -335,9 +336,9 @@ def Run(self, cmd_val): tzcell = self.mem.GetCell('TZ') if tzcell and tzcell.exported and tzcell.val.tag_() == value_e.Str: tzval = cast(value__Str, tzcell.val) - os.environ['TZ'] = tzval.s - elif 'TZ' in os.environ: - del os.environ['TZ'] + posix.putenv('TZ', tzval.s) + elif posix.getenv('TZ'): + posix.unsetenv('TZ') time.tzset() # Handle special values: