Parsing the/etc/profile file in fedora14
Analyze the/etc/profile environment variable file in shell scripts
// A function in the pathmunge () shell program. path is the default path for Linux to search for commands. $1 generally represents the default path. For example, run source/etc/profile on the command line. $2 if it is after, it indicates that the path is changed to $ PATH $1
Pathmunge (){
Case $ {path} in
$1)
;;
*)
If [$2 = after]; then
Path = $ PATH $1
Else
Path = $1 $ path
Fi
Esac
}
// Check whether/usr/bin/ID is executable before checking the variable EUID (valid user ID). If it is null, initialize the variables EUID and uid
If [-x/usr/bin/ID]; then
If [-z "$ EUID"]; then
# KSh workaround
EUID = 'id-U'
Uid = 'id-Ru'
Fi
User = "'id-UN '"
LOGNAME = $ user
Mail = "/var/spool/mail/$ user"
Fi
// Judge, if it is a root user, add/sbin,/usr/sbin/usr/local/sbin,/opt/friendlyarm/toolschain/4.4.3/bin to the PATH variable.
If ["$ EUID" = "0"]; then
Pathmunge/sbin
Pathmunge/usr/sbin
Pathmunge/usr/local/sbin
Pathmunge/opt/friendlyarm/toolschain/4.4.3/bin
Else
Pathmunge/usr/local/sbin after
Pathmunge/usr/sbin after
Pathmunge/sbin after
Fi
Hostname = '/bin/hostname 2>/dev/null'
// Indicates the maximum number of command PWD commands that can be run three times in a row when the history command is input. After history is executed, you will see three duplicate entries. To remove these duplicate entries, you can set histcontrol to ignoredups: Use histcontrol to force history not to remember specific commands and set histcontrol to ignorespace, enter a space before the command that you do not want to remember.
History Size = 1000
If ["$ histcontrol" = "ignorespace"]; then
Export histcontrol = ignoreboth
Else
Export histcontrol = ignoredups
Fi
// Set the variables initialized above as Environment Variables
Export path user LOGNAME mail hostname histsize histcontrol
// PS1 is the basic prompt. For example, if the root user is #, the common user is $
// PS2 is an auxiliary prompt, such as>
// Finally Delete the variables and functions used in this script
// Execute all script files in the/etc/profile. d/directory.
For I in/etc/profile. d/*. Sh; do
If [-R "$ I"]; then
If ["$ PS1"]; then
. $ I
Else
. $ I>/dev/null 2> & 1
Fi
Fi
Done
// Finally Delete the variables and functions used in this script
Unset I
Unset pathmunge