mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Make sure USER variable is correct. Needed when using the su command.
darcs-hash:20051023102232-ac50b-4ed7c9de75ece8a1d9ba7ec5c086bde146436db9.gz
This commit is contained in:
parent
fc5e0ab367
commit
ba6ad5025e
|
@ -503,7 +503,7 @@ inherited by any commands started by fish. It is convention that
|
|||
exported variables are in uppercase and unexported variables are in
|
||||
lowercase.
|
||||
|
||||
Variables can be explicitly set to be exportes with the \c -x or \c
|
||||
Variables can be explicitly set to be exported with the \c -x or \c
|
||||
--export switch, or not exported with the \c -u or \c --unexport
|
||||
switch. The exporting rules when creating or updating a variable are
|
||||
identical to the scoping rules for variables:
|
||||
|
@ -557,7 +557,7 @@ echo $smurf
|
|||
\subsection variables-special Special variables
|
||||
|
||||
The user can change the settings of \c fish by changing the values of
|
||||
certain environment variables.These are:
|
||||
certain environment variables.
|
||||
|
||||
- \c BROWSER, which is the users preferred web browser. If this variable is set, fish will use the specified browser instead of the system default browser to display the fish documentation.
|
||||
- \c CDPATH, which is an array of directories in which to search for the new directory for the \c cd builtin.
|
||||
|
@ -569,12 +569,15 @@ values of certain environment variables. The user can not change the values of t
|
|||
|
||||
- \c _, which is the name of the currently running command.
|
||||
- \c history, which is an array containing the last commands that where entered
|
||||
- \c HOME, which is the users home directory. This variable can be changed by the root user.
|
||||
- \c HOME, which is the users home directory. This variable can only be changed by the root user.
|
||||
- \c PWD, which is the current working directory.
|
||||
- \c status, which is the exit status of the last foreground job to exit. If a job contains pipelines, the status of the last command in the pipeline is the status for the job.
|
||||
- \c USER, which is the username. This variable can only be changed by the root user.
|
||||
|
||||
\c fish also uses several variables internally. Such variables are
|
||||
prefixed with the string __FISH or __fish. These should be ignored by the user.
|
||||
Variables whose name are in uppercase are exported to the commands
|
||||
started by fish. \c fish also uses several variables internally. Such
|
||||
variables are prefixed with the string __FISH or __fish. These should
|
||||
be ignored by the user.
|
||||
|
||||
\section builtin-overview Builtins
|
||||
|
||||
|
|
17
env.c
17
env.c
|
@ -234,6 +234,8 @@ static void universal_callback( int type,
|
|||
void env_init()
|
||||
{
|
||||
char **p;
|
||||
struct passwd *pw;
|
||||
wchar_t *uname;
|
||||
|
||||
sb_init( &dyn_var );
|
||||
|
||||
|
@ -253,11 +255,14 @@ void env_init()
|
|||
hash_put( &env_read_only, L"PWD", L"" );
|
||||
|
||||
/*
|
||||
HOME should be writeable by root, since this is often a
|
||||
HOME and USER should be writeable by root, since this can be a
|
||||
convenient way to install software.
|
||||
*/
|
||||
if( getuid() != 0 )
|
||||
{
|
||||
hash_put( &env_read_only, L"HOME", L"" );
|
||||
hash_put( &env_read_only, L"USER", L"" );
|
||||
}
|
||||
|
||||
top = malloc( sizeof(env_node_t) );
|
||||
top->next = 0;
|
||||
|
@ -266,7 +271,7 @@ void env_init()
|
|||
hash_init( &top->env, &hash_wcs_func, &hash_wcs_cmp );
|
||||
global_env = top;
|
||||
global = &top->env;
|
||||
|
||||
|
||||
/*
|
||||
Import environment variables
|
||||
*/
|
||||
|
@ -300,8 +305,12 @@ void env_init()
|
|||
env_set( key, val, ENV_EXPORT | ENV_GLOBAL );
|
||||
}
|
||||
free(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pw = getpwuid( getuid() );
|
||||
uname = str2wcs( pw->pw_name );
|
||||
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT );
|
||||
|
||||
env_universal_init( env_get( L"FISHD_SOKET_DIR"),
|
||||
env_get( L"USER" ),
|
||||
&start_fishd,
|
||||
|
|
Loading…
Reference in New Issue
Block a user