1
0

Compare commits

...

5 Commits

Author SHA1 Message Date
DTB
bdd388e6d4 Retire p 2024-07-23 18:09:26 -06:00
DTB
c10ffcabf1 retire retval 2024-07-23 17:48:47 -06:00
DTB
de267d32d4 retval(1): whatever 2024-07-23 17:48:26 -06:00
DTB
4a405fdfbb retval(1): fix style 2024-07-23 17:47:37 -06:00
DTB
df1b0a2d9d move pschdir(1) to retirement 2024-07-23 17:26:55 -06:00
9 changed files with 25 additions and 25 deletions

24
Retired/retval/retval.c Normal file
View File

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

View File

@ -1,7 +1,7 @@
use std::{env::args, process::ExitCode}; use std::{env::args, process::ExitCode};
fn usage(s: &str) -> ExitCode { fn usage(s: &str) -> ExitCode {
eprintln!("Usage: {} [status]", s); eprintln!("Usage: {} status", s);
ExitCode::from(64 /* NetBSD sysexits(3) EX_USAGE */) ExitCode::from(64 /* NetBSD sysexits(3) EX_USAGE */)
} }

View File

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