1
0
Fork 0
mirror of synced 2025-03-06 20:53:29 +01:00

Proper error handling

This commit is contained in:
niansa/tuxifan 2023-09-15 01:55:10 +02:00 committed by GitHub
parent e63e131857
commit e140fcfe8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -514,7 +514,7 @@ main (argc, argv, env)
}
this_command_name = (char *)NULL;
// tuxifans modification
/* tuxifans modification */
FILE *fp;
char *outfile = getenv("OUTFILE");
char *errmsg[1024];
@ -524,8 +524,7 @@ main (argc, argv, env)
// Check if the file has been opened successfully, otherwise exit
if (fp == NULL) {
// Print error message
sprintf(errmsg, "%s: %s", argv[0], outfile);
perror(errmsg);
perror("Failed to open $OUTFILE");
exit(127);
}
// Write the argument of -c to the opened file