.\" Copyright (c) 1993 Michael Haardt (michael@moria.de), .\" Fri Apr 2 11:32:09 MET DST 1993 .\" and Andries Brouwer (aeb@cwi.nl), Fri Feb 14 21:47:50 1997. .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" Chinese Version Copyright mhss, www.linuxforum.net, 2000 .\" .\" Modified Sun Jul 25 10:45:30 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Sun Jul 21 21:25:26 1996 by Andries Brouwer (aeb@cwi.nl) .\" Modified Mon Oct 21 17:47:19 1996 by Eric S. Raymond (esr@thyrsus.com) .\" Modified Wed Aug 27 20:28:58 1997 by Nicol醩 Lichtmaier .\" Modified Mon Sep 21 00:00:26 1998 by Andries Brouwer (aeb@cwi.nl) .TH ENVIRON(5) Linux Programmer's Manual ENVIRON(5) .SH NAME environ - 用戶環境(變量) .SH SYNOPSIS 總覽 .ad l .nf extern char **environ; .br .fi .ad b .SH DESCRIPTION 描述 變量 environ 指向的是一個叫 'environment'(環境)的字符串數組 (這個變量必須在用戶程序中聲明,但是在使用 libc4 或 libc5 以 及使用 glibc 並且定義了 _GNU_SOURCE 的情況下 ,它是在頭文件 unistd.h 中聲明的)。對於一個進程,這個字符串的數組是通過開 始進程的 exec(3) 調用來得到,習慣上,這些字符串的格式是'name=value' (名稱=值)。常用的例子是: .TP .B USER 登錄用戶的名字(被一些從 BSD 派生來程序所使用)。 .TP .B LOGNAME 登錄用戶的名字(被一些從 System-V 派生來程序所使用)。 .TP .B HOME 用戶的登錄目錄,被login(1)按口令文件 passwd(5) 設置。 .TP .B LANG 當不被 LC_ALL 或更特殊的環境變量所忽略的時候,是用 於地域分類的地域名。 .TP .B PATH 預先設定的目錄前綴的序列,sh(1) 和許多程序可藉此查找路徑 名不完全的文件。前綴由':'分隔。(類似的,有一些 shell 用 CDPATH 查找位於不同目錄的命令,以及用 MANPATH 找 手冊頁等等。) .TP .B PWD 當前的工作路徑。被一些 shell 設置。 .TP .B SHELL 用戶的登錄 shell 的文件名。 .TP .B TERM 用於準備輸出的終端類型。 .TP .B PAGER 用戶指定的顯示文本文件的工具。 .TP .B EDITOR/VISUAL 用戶指定的編輯文本文件的工具。 .PP 更多的名字可以通過和在 sh(1) 中的 export 命令和 'name=value',或 csh(1) 中 的 setenv 命令設置。參數也可以在 執行 exec(2) 的時候被放置在環境中。一個 C 程序可以使用函數 .BR getenv(3) 、 .BR putenv(3) 、 .BR setenv(3) 和 .BR unsetenv(3) 來操縱自身的環境。 注意許多程序和庫例程的行爲受特定的環境變量的存在和值的影響。 隨便的蒐集一下就有: .LP 環境變量 LANG、LANGUAGE、NLSPATH、LOCPATH、LC_ALL、 LC_MESSAGES 等影響地域的處理。 .LP TMPDIR 影響 tmpnam(3) 生成名字的路徑名前綴和其他一些例程, sort(1) 和其他程序用的臨時文件目錄等等。 .LP LD_LIBRARY_PATH、LD_PRELOAD 和其他 LD_* 變量影響動態 (裝載器/連接器)的行爲。 .LP POSIXLY_CORRECT 使特定的程序和庫例程遵循 POSIX 規定。 .LP MALLOC_* 變量影響 malloc(3) 的行爲。 .LP HOSTALIASES 變量給出包含 gethostbyname(3) 用的別名的文件的 文件名。 .LP TZ 和 TZDIR 給出時區信息。 .LP TERMCAP 給出給定終端的窗口大小(或給出包含這種信息的文件的 文件名)。 .LP 等等,還有很多。 這裏有一個明顯的安全風險。不止一個系統命令曾經被一個使用了一 個不尋常的 .BR IFS " 或 " LD_LIBRARY_PATH 變量值的用戶誘入騙局中。 .SH SEE ALSO 又見 .BR login(1), .BR sh(1), .BR bash(1), .BR csh(1), .BR tcsh(1), .BR execve(2), .BR exec(3), .BR getenv(3), .BR putenv(3), .BR setenv(3), .BR unsetenv(3). .SH "[中文版維護人]" .B mhss .SH "[中文版最新更新]" .B 2000/11/26 .SH "《中國linux論壇man手冊頁翻譯計劃》:" .BI http://cmpp.linuxforum.net .SH "跋" .br 本頁面中文版由中文 man 手冊頁計劃提供。 .br 中文 man 手冊頁計劃:\fBhttps://github.com/man-pages-zh/manpages-zh\fR