Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Commit 4cc454b

Browse files
author
NerdOfCode
committed
Patched
In some cases, the wrong error code would be compared, thus, causing errors to be printed
1 parent 688c675 commit 4cc454b

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Src/shell.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,15 @@ void change_to_home_dir( void ){
208208
//Assume users directory is /home/logged_in_user
209209

210210
//For chdir() return code
211-
short int return_status = 0;
211+
short int ret = 0;
212212

213213
char current_user_home[64] = "/home/";
214214
strcat(current_user_home,logged_in_user);
215215

216216
//chdir() return -1 on error and 0 on success
217-
if(chdir(current_user_home) == -1)
217+
ret = chdir(current_user_home);
218+
219+
if(ret == -1)
218220
puts(RED_TEXT"Error: 1005"RESET);
219221

220222
}
@@ -487,7 +489,7 @@ int update_new_cd( int update ){
487489
fptr = fopen(cwd_file, "r");
488490

489491
if(fptr != NULL){
490-
if(fscanf(fptr, "%s", cd_buffer) == EOF)
492+
if(fscanf(fptr, "%s", cd_buffer) == 0)
491493
printf("Error: reading change directory");
492494
}else{
493495
return -1;
@@ -507,14 +509,12 @@ int update_new_cd( int update ){
507509
//Delete old cwd file
508510
if(truncate(cwd_file, 0) == -1)
509511
printf("Error: unable to overwrite old 'cwd' file.");
510-
511-
if(chdir(cd_buffer) == -1)
512-
puts(RED_TEXT"Error: 1005"RESET);
512+
//Pretty much useless for now....
513+
short int ret = chdir(cd_buffer);
513514
memset(cd_buffer, 0, sizeof(cd_buffer));
514515
}else{
515516
//We should probably add a security mechanism here at a later date... 4/17/18
516-
if(chdir(cd_buffer) == -1)
517-
puts(RED_TEXT"Error: 1005"RESET);
517+
short int ret = chdir(cd_buffer);
518518
}
519519

520520

0 commit comments

Comments
 (0)