-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathf_error.c
More file actions
33 lines (30 loc) · 754 Bytes
/
f_error.c
File metadata and controls
33 lines (30 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "shell.h"
/**
* dispatch_error - Dispatches an error
* @msg: Message to print as error
*/
void dispatch_error(char *msg)
{
/* int len = _strlen(msg); */
perror(msg);
/*write(STDERR_FILENO, msg, len);*/
/*write(STDERR_FILENO,": not found\n", 12);*/
exit(errno);
/*exit(127); */
}
/**
* print_builtin_error - Prints error for buitin function
* @msg: Error message
* @arg: Argument passed to builtin
*/
void print_builtin_error(char *msg, char *arg)
{
int len = _strlen(msg);
char *first_av = get_first_av();
write(STDERR_FILENO, first_av, _strlen(first_av));
write(STDERR_FILENO, ": 1: ", 5);
write(STDERR_FILENO, msg, len);
write(STDERR_FILENO, arg, _strlen(arg));
write(STDERR_FILENO, "\n", 1);
set_process_exit_code(2);
}