1
0

cope with no argv0, use libio

This commit is contained in:
dtb 2022-06-14 17:06:39 -04:00
parent 0f7c7985ba
commit 747bbbc31b

View File

@ -1,16 +1,18 @@
#include <stddef.h> /* NULL */
#include <sysexits.h> /* EX_USAGE */
#include <unistd.h> /* execv(3), write(2) */
#include "noargvzero.h"
#include "libio.h" /* fdprint(3) */
static char *program_name = "simexec";
int main(int argc, char *argv[]){
int i;
NOARGVZERO(argv);
if(argc < 2){
write(2, "Usage: ", 7);
for(i = 0; argv[0][i] != '\0'; ++i);
write(2, argv[0], i);
if(argv[0] == NULL)
argv[0] = program_name;
fdprint(2, argv[0]);
write(2, " [pathname], [argv...]\n", 23);
return EX_USAGE;
}