1 #define _POSIX_C_SOURCE 200809L
3 #include <errno.h> // ENOMEM,errno
4 #include <locale.h> // LC_ALL,setlocale
5 #include <signal.h> // SIGHUP,raise
6 #include <stdio.h> // ferror,fputs,getline,perror,ssize_t,stderr,stdin
7 #include <stdlib.h> // EXIT_FAILURE,NULL,malloc,size_t
8 #include <unistd.h> // execv
11 setlocale(LC_ALL
, "");
14 ssize_t len
= getline(&line
, &size
, stdin
);
17 perror("minish-once");
22 // NOTE len cannot be 0
23 if (line
[len
- 1] == '\n') {
27 for (char* s
= line
; s
< line
+ len
; ++s
) {
32 char** const argv
= malloc(words
* sizeof(char*));
35 perror("minish-once: malloc()");
40 for (char* s
= line
; s
< line
+ len
; ++s
) {
47 fputs("minish-once: ", stderr
);