1
0

independ pscat(1)

This commit is contained in:
dtb 2022-09-13 00:52:52 -04:00
parent ec717feb5f
commit 97c96d1063
4 changed files with 60 additions and 17 deletions

View File

@ -93,11 +93,13 @@ nutshell.o: libio usefulmacros src/nutshell.c src/nutshell.h src/nutshell_builti
nutshell: libio nutshell.o
$(CC) $(CFLAGS) -o bin/nutshell build/libio.o build/nutshell.o
pscat.o: libio src/pscat.c
$(CC) $(CFLAGS) -c -o build/pscat.o src/pscat.c
pscat: bin/pscat
pscat: libio pscat.o
$(CC) $(CFLAGS) -o bin/pscat build/libio.o build/pscat.o
bin/pscat: pscat/pscat
mv pscat/pscat bin/pscat
pscat/pscat: sysexits pscat/pscat.c pscat/Makefile
$(MAKE) -C pscat sane
retval.o: libio src/retval.c sysexits
$(CC) $(CFLAGS) -c -o build/retval.o src/retval.c
@ -105,13 +107,17 @@ retval.o: libio src/retval.c sysexits
retval: libio retval.o
$(CC) $(CFLAGS) -o bin/retval build/retval.o build/libio.o
roll: roll/roll
roll: bin/roll
bin/roll: roll/roll
mv roll/roll bin/roll
roll/roll: sysexits roll/roll.c roll/Makefile
$(MAKE) -C roll sane
rot13: rot13/rot13
rot13: bin/rot13
bin/rot13: rot13/rot13
mv rot13/rot13 bin/rot13
rot13/rot13: sysexits rot13/rot13.c rot13/Makefile
@ -288,4 +294,4 @@ unscii-user:
curl "http://viznut.fi/unscii/unscii-16-full.pcf" >"~/.fonts/unscii-16-full.pcf"
curl "http://viznut.fi/unscii/unscii-16-full.ttf" >"~/.fonts/unscii-16-full.ttf"
.PHONY: all clean cleanlibraries cleanprograms stdbool sysexits usefulmacros
.PHONY: all clean cleanlibraries cleanprograms pscat roll rot13 stdbool sysexits usefulmacros

28
pscat/Makefile Normal file
View File

@ -0,0 +1,28 @@
all: pscat
clean:
rm -rf ../dist/pscat ../dist/pscat.tar ../dist/pscat.tar.gz pscat
dist: ../dist/pscat.tar.gz
sane: pscat.c ../include/sysexits.h
$(CC) -DUSE_ASCII_H -DDONT_USE_SYSTEM_SYSEXITS -o pscat pscat.c
pscat: pscat.c
$(CC) -o pscat pscat.c
../dist/pscat: pscat
mkdir -p ../dist/pscat.tmp/bin/ ../dist/pscat.tmp/share/man/man1/
cp pscat ../dist/pscat.tmp/bin/pscat
cp pscat.1 ../dist/pscat.tmp/share/man/man1/pscat.1
mv ../dist/pscat.tmp ../dist/pscat
../dist/pscat.tar: ../dist/pscat
cd ../dist/pscat && pax -w -x ustar . >../pscat.tar.tmp
mv ../dist/pscat.tar.tmp ../dist/pscat.tar
../dist/pscat.tar.gz: ../dist/pscat.tar
gzip -c <../dist/pscat.tar >../dist/pscat.tar.gz.tmp
mv ../dist/pscat.tar.gz.tmp ../dist/pscat.tar.gz
.PHONY: all clean sane

View File

@ -1,15 +1,25 @@
#include <ascii.h>
#ifndef DONT_USE_SYSTEM_SYSEXITS
# include <sysexits.h>
#else
# include "../include/sysexits.h"
#endif /* ifndef DONT_USE_SYSTEM_SYSEXITS */
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#include "libio.h"
static char *program_name = "pscat";
/* Originally designed to use parentheses but changed to brackets to escape the
* hassle of escaping them from the Bourne shell. */
#ifndef USE_ASCII_H
# define L_PAREN '['
# define R_PAREN ']'
#else
# include "../include/ascii.h"
# define L_PAREN ASCII_LEFT_SQUARE_BRACKET
# define R_PAREN ASCII_RIGHT_SQUARE_BRACKET
#endif /* ifndef USE_ASCII_H */
/* Test string containing { c, '\0' } without iteration.
* Theoretically saves a little bit of time compared to strcmp(3). */
@ -53,7 +63,6 @@ check_arg(char **argv){
}
int main(int argc, char *argv[]){
char *argv0;
char **psstart;
int child;
int i;
@ -61,13 +70,13 @@ int main(int argc, char *argv[]){
int retval;
int terms;
argv0 = argv[0] == NULL ? program_name : argv[0];
retval = 0;
if((terms = check_arg(++argv)) == 0){
write(2, "Usage: ", 7);
fdprint(2, argv0);
write(2, " \"[\" [utility [argument...]] \"]\" ...\n", 37);
fprintf(stderr,
"Usage: %s \"[\" [utility [argument...]] \"]\" ...\n",
argv[0] == NULL ? program_name : argv[0]
);
return EX_USAGE;
}