1
0
src/retval/retval.c
2023-11-18 14:56:17 -07:00

24 lines
484 B
C

#include <errno.h> /* errno */
#include <stdio.h> /* fprintf(3), stderr */
#include <stdlib.h> /* strtol(3) */
#include <sysexits.h> /* EX_USAGE */
static char *program_name = "retval";
int main(int argc, char *argv[]){
unsigned int s;
if(argc < 2)
goto usage;
errno = 0;
s = strtol(argv[1], &argv[1], 10);
if(*argv[1] != '\0' || errno != 0){
usage: fprintf(stderr, "Usage: %s [status]\n",
argv[0] == NULL ? program_name : argv[0]);
return EX_USAGE;
}
return s;
}