.\" -*- coding: UTF-8 -*- '\" t .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Single UNIX Specification, Version 2 .\" Modified Thu Apr 8 15:00:12 1993, David Metcalfe .\" Modified Sat Jul 24 18:44:45 1993, Rik Faith (faith@cs.unc.edu) .\" Modified Fri Feb 14 21:47:50 1997 by Andries Brouwer (aeb@cwi.nl) .\" Modified Mon Oct 11 11:11:11 1999 by Andries Brouwer (aeb@cwi.nl) .\" Modified Wed Nov 10 00:02:26 1999 by Andries Brouwer (aeb@cwi.nl) .\" Modified Sun May 20 22:17:20 2001 by Andries Brouwer (aeb@cwi.nl) .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH putenv 3 "23 июля 2024 г." "Linux man\-pages 6.12" .SH НАИМЕНОВАНИЕ putenv \- изменяет или добавляет переменную окружения .SH БИБЛИОТЕКА Standard C library (\fIlibc\fP,\ \fI\-lc\fP) .SH ОБЗОР .nf \fB#include \fP .P .\" Not: const char * \fBint putenv(char *\fP\fIstring\fP\fB);\fP .fi .P .RS -4 Требования макроса тестирования свойств для glibc (см. \fBfeature_test_macros\fP(7)): .RE .P \fBputenv\fP(): .nf _XOPEN_SOURCE || /* glibc >= 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _SVID_SOURCE .fi .SH ОПИСАНИЕ Функция \fBputenv\fP() добавляет или изменяет значение переменных окружения. Аргумент \fIstring\fP должен быть представлен в форме \fIname\fP=\fIvalue\fP. Если переменной с именем \fIname\fP нет в окружении, то \fIstring\fP добавляется к окружению. Если переменная \fIname\fP уже существует, то значение \fIname\fP в окружении изменяется на \fIvalue\fP. Строка, на которую указывает \fIstring\fP, становится частью окружения, так что её изменение приведёт к изменению окружения. .SH "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ" The \fBputenv\fP() function returns zero on success. On failure, it returns a nonzero value, and \fIerrno\fP is set to indicate the error. .SH ОШИБКИ .TP \fBENOMEM\fP Недостаточно памяти под новое окружение. .SH АТРИБУТЫ Описание терминов данного раздела смотрите в \fBattributes\fP(7). .TS allbox; lbx lb lb l l l. Интерфейс Атрибут Значение T{ .na .nh \fBputenv\fP() T} Безвредность в нитях MT\-Unsafe const:env .TE .SH СТАНДАРТЫ POSIX.1\-2008. .SH ИСТОРИЯ POSIX.1\-2001, SVr2, 4.3BSD\-Reno. .P .\" .P .\" Description for libc4, libc5, glibc: .\" If the argument \fIstring\fP is of the form \fIname\fP, .\" and does not contain an \[aq]=\[aq] character, then the variable \fIname\fP .\" is removed from the environment. .\" If .\" .BR putenv () .\" has to allocate a new array \fIenviron\fP, .\" and the previous array was also allocated by .\" .BR putenv (), .\" then it will be freed. .\" In no case will the old storage associated .\" to the environment variable itself be freed. От функции \fBputenv\fP() не требуется быть реентерабельной, и она такова в glibc 2.0, но в glibc 2.1 она реентерабельна. .P Since glibc 2.1.2, the glibc implementation conforms to SUSv2: the pointer \fIstring\fP given to \fBputenv\fP() is used. In particular, this string becomes part of the environment; changing it later will change the environment. (Thus, it is an error to call \fBputenv\fP() with an automatic variable as the argument, then return from the calling function while \fIstring\fP is still part of the environment.) However, from glibc 2.0 to glibc 2.1.1, it differs: a copy of the string is used. On the one hand this causes a memory leak, and on the other hand it violates SUSv2. .P The 4.3BSD\-Reno version, like glibc 2.0, uses a copy; this is fixed in all modern BSDs. .P В SUSv2 удалено \fIconst\fP из прототипа и это сделано в glibc 2.1.3. .P Реализация библиотеки GNU C предоставляет нестандартное расширение. Если \fIstring\fP не включает знака равно: .P .in +4n .EX putenv("NAME"); .EE .in .P то именованная переменная удаляется из окружения вызывающего. .SH "СМОТРИТЕ ТАКЖЕ" \fBclearenv\fP(3), \fBgetenv\fP(3), \fBsetenv\fP(3), \fBunsetenv\fP(3), \fBenviron\fP(7) .PP .SH ПЕРЕВОД Русский перевод этой страницы руководства разработал(и) Alexey, Azamat Hackimov , kogamatranslator49 , Darima Kogan , Max Is , Yuri Kozlov , Иван Павлов и Kirill Rekhov . .PP Этот перевод является свободной программной документацией; он распространяется на условиях общедоступной лицензии GNU (GNU General Public License - GPL, .UR https://www.gnu.org/licenses/gpl-3.0.html .UE версии 3 или более поздней) в отношении авторского права, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ. .PP Если вы обнаружите какие-либо ошибки в переводе этой страницы руководства, пожалуйста, сообщите об этом разработчику(ам) по его(их) адресу(ам) электронной почты или по адресу .MT списка рассылки русских переводчиков .ME .