1
0

address oft-noted 'bug'

This commit is contained in:
dtb 2022-08-24 17:08:34 -04:00
parent b3cd51242c
commit 3a849ed4c0
2 changed files with 4 additions and 52 deletions

View File

@ -27,6 +27,10 @@ Pscat will exit with the sum of the child processes' exit statuses if run correc
Pscat's exit status isn't useful when run correctly; there's no way to tell which process failed if one did.
This issue of ergonomics isn't obviously mendable as processes' standard outputs and standard errors are meant to both be conveyed.
If either could be ignored the individual exit statuses could simply be printed.
.PP
Pscat's function is redundant to the sh(1) construct
.RB { utility ; utility ;}
- this is a feature, not a bug.
.SH COPYRIGHT

View File

@ -1,52 +0,0 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
/* on some non-POSIX systems this may need to be "rb" */
#define READ_MODE "r"
const char *WHITESPACE = " \t\r\n";
/* This function checks if the *****REST****** of the file is blank. It does
* not rewind the file first. */
bool
file_is_blank(FILE *f){
int c;
while(strchr(WHITESPACE, (c = getc(f))) != NULL);
return c == EOF;
}
void
usage(char *name){
fprintf(stderr, "Usage: %s <file...>\n", argv[0]);
exit(1);
}
int main(int argc, char **argv){
char *argv0;
FILE *fp[argc-1];
int fd;
int i;
struct stat s;
argv0 = argv[0];
--argc; ++argv;
if(argc < 2)
usage(argv0);
for(i = 0; i < argc; ++i){
if((fp[i] = fopen(argv[i], READ_MODE)) == NULL){
fprintf(stderr,
"%s: %s: Error opening file for reading.\n",
argv0, argv[i]);
return 1;
}
}
/* UNREACHABLE */
return 0;
}