mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 19:03:38 +08:00
Minor code simplification in main.c
darcs-hash:20061111110650-ac50b-0d50d10087ea863ff0c79d05c614fdb06fa3b9bd.gz
This commit is contained in:
parent
8784b78d84
commit
d59d3b4463
19
main.c
19
main.c
|
@ -73,17 +73,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
static int read_init()
|
static int read_init()
|
||||||
{
|
{
|
||||||
char cwd[4096];
|
wchar_t cwd[4096];
|
||||||
wchar_t *wcwd;
|
|
||||||
|
|
||||||
wchar_t *config_dir;
|
wchar_t *config_dir;
|
||||||
wchar_t *config_dir_escaped;
|
wchar_t *config_dir_escaped;
|
||||||
void *context;
|
void *context;
|
||||||
string_buffer_t *eval_buff;
|
string_buffer_t *eval_buff;
|
||||||
|
|
||||||
if( !getcwd( cwd, 4096 ) )
|
if( !wgetcwd( cwd, 4096 ) )
|
||||||
{
|
{
|
||||||
wperror( L"getcwd" );
|
wperror( L"wgetcwd" );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,20 +101,17 @@ static int read_init()
|
||||||
halloc_free( context );
|
halloc_free( context );
|
||||||
free( config_dir_escaped );
|
free( config_dir_escaped );
|
||||||
|
|
||||||
if( chdir( cwd ) == -1 )
|
if( wchdir( cwd ) == -1 )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
If we can't change back to previos directory, we go to
|
If we can't change back to previos directory, we go to
|
||||||
~. Should be a sane default behavior.
|
~. Should be a sane default behavior.
|
||||||
*/
|
*/
|
||||||
eval( L"builtin cd", 0, TOP );
|
eval( L"builtin cd", 0, TOP );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
wcwd = str2wcs( cwd );
|
|
||||||
if( wcwd )
|
|
||||||
{
|
{
|
||||||
env_set( L"PWD", wcwd, ENV_EXPORT );
|
env_set( L"PWD", cwd, ENV_EXPORT );
|
||||||
free( wcwd );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user