peek(1): remove -p

This commit is contained in:
dtb 2024-04-18 09:08:08 -06:00
parent 3b774cab27
commit 23521bade5
Signed by: trinity
GPG Key ID: 34C0543BBB6AF81B

View File

@ -25,8 +25,7 @@
# include <sysexits.h> # include <sysexits.h>
#endif #endif
#include <termios.h> /* tcgetattr(3), tcsetattr(3), struct termios, ECHO */ #include <termios.h> /* tcgetattr(3), tcsetattr(3), struct termios, ECHO */
#include <unistd.h> /* dup(2), execvp(3), fork(2), getopt(3), isatty(3), #include <unistd.h> /* getopt(3), isatty(3), STDIN_FILENO */
* pipe(2), STDIN_FILENO */
static int oserr(char *s){ perror(s); return EX_OSERR; } static int oserr(char *s){ perror(s); return EX_OSERR; }
@ -59,29 +58,23 @@ int main(int argc, char *argv[]){
char include_eof; char include_eof;
FILE *outputs[] = { FILE *outputs[] = {
NULL /* stdout */, NULL /* stdout */,
NULL /* stderr */, NULL /* stderr */
NULL /* -p */
}; };
int p[2] = {0, 0};
if(argc < 1) if(argc < 1)
usage(argv[0]); return usage(argv[0]);
eof = EOF; eof = EOF;
include_eof = 0; include_eof = 0;
{ /* options parsing */ { /* options parsing */
int c; int c;
while((c = getopt(argc, argv, "1enopt")) != -1) while((c = getopt(argc, argv, "1enot")) != -1)
switch(c){ switch(c){
case '1': eof = '\n'; break; case '1': eof = '\n'; break;
case 'n': include_eof = 1; break; case 'n': include_eof = 1; break;
case 'o': outputs[0] = stdout; break; case 'o': outputs[0] = stdout; break;
case 'e': outputs[1] = stderr; break; case 'e': outputs[1] = stderr; break;
case 'p':
if(pipe(p) != 0 || (outputs[2] = fdopen(p[1], "ab")) == NULL)
return oserr(argv[0]);
break;
case 't': case 't':
if(isatty(STDIN_FILENO) != 1){ if(isatty(STDIN_FILENO) != 1){
fprintf(stderr, "%s: Must be run in a terminal" fprintf(stderr, "%s: Must be run in a terminal"