diff --git a/main.c b/main.c index a55f834df..a82b39781 100644 --- a/main.c +++ b/main.c @@ -73,17 +73,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ static int read_init() { - char cwd[4096]; - wchar_t *wcwd; - + wchar_t cwd[4096]; wchar_t *config_dir; wchar_t *config_dir_escaped; void *context; string_buffer_t *eval_buff; - if( !getcwd( cwd, 4096 ) ) + if( !wgetcwd( cwd, 4096 ) ) { - wperror( L"getcwd" ); + wperror( L"wgetcwd" ); return 0; } @@ -103,20 +101,17 @@ static int read_init() halloc_free( context ); free( config_dir_escaped ); - if( chdir( cwd ) == -1 ) + if( wchdir( cwd ) == -1 ) { /* If we can't change back to previos directory, we go to ~. Should be a sane default behavior. */ eval( L"builtin cd", 0, TOP ); - } - - wcwd = str2wcs( cwd ); - if( wcwd ) + } + else { - env_set( L"PWD", wcwd, ENV_EXPORT ); - free( wcwd ); + env_set( L"PWD", cwd, ENV_EXPORT ); } return 1;