tailieunhanh - Mac OS X Server Introduction to Command-Line Administration Version 10.6 Snow Leopard phần 3
Vỏ sử dụng biến môi trường để lưu trữ thông tin, chẳng hạn như tên của người sử dụng hiện tại, tên của máy chủ và đường dẫn mặc định cho bất kỳ lệnh. Biến môi trường được thừa hưởng tất cả các lệnh được thực hiện trong bối cảnh của vỏ, và một số lệnh phụ thuộc vào biến môi trường. Bạn có thể tạo ra các biến môi trường | Using Environment Variables The shell uses environment variables to store information such as the name of the current user the name of the host computer and the default paths to any commands. Environment variables are inherited by all commands executed in the shell s context and some commands depend on environment variables. You can create environment variables and use them to control the behavior of a command without modifying the command itself. For example you can use an environment variable to have a command print debug information to the console. To set the value of an environment variable use the appropriate shell command to associate a variable name with a value. For example to set the variable PATH to the value bin sbin user bin user sbin system Library you would enter the following command in a Terminal window PATH bin sbin user bin user sbin system Library export PATH This modifies the environment variable PATH with the value assigned. To view all environment variables enter env When you launch an application from a shell the application inherits much of the shell s environment including exported environment variables. This form of inheritance can be a useful way to configure the application dynamically. For example your application can check for the presence or value of an environment variable and change its behavior accordingly. Different shells support different semantics for exporting environment variables. For information see the man page for your preferred shell. Although child processes of a shell inherit the environment of that shell shells are separate execution contexts that don t share environment information with each other. Variables you set in one Terminal window aren t set in other Terminal windows. After you close a Terminal window variables you set in that window are gone. If you want the value of a variable to persist across sessions and in all Terminal windows you must set it in a shell startup script. For information about modifying .
đang nạp các trang xem trước