From fc4f1875fe57c39bf122cfb43a30893fef58c157 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sat, 3 Feb 2024 17:54:02 +0100 Subject: reapeat now built using the GNU Autotools --- Makefile | 37 ------------------- Makefile.am | 4 ++ configure.ac | 11 ++++++ rpt.1 | 117 ----------------------------------------------------------- rpt.1.in | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rpt.c | 6 +-- 6 files changed, 134 insertions(+), 158 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 configure.ac delete mode 100644 rpt.1 create mode 100644 rpt.1.in diff --git a/Makefile b/Makefile deleted file mode 100644 index 1f59519..0000000 --- a/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -PREFIX = /usr/local - -CFLAGS = -std=c99 -Wall -Wextra -pedantic -O0 -ggdb - -BIN = rpt -SRC = rpt.c -OBJ = rpt.o - -MAN_SRC = rpt.1 -MAN_PAGE = rpt.1.gz - -.PHONY: all compile man clean install uninstall - -all: compile man - -compile: $(BIN) - -$(BIN): $(OBJ) - cc $^ -o $@ - -%.o: %.c - cc $(CFLAGS) -c $< -o $@ - -man: $(MAN_PAGE) - -%.1.gz: %.1 - gzip -9 -c $< > $@ - -clean: - rm -f $(BIN) $(OBJ) $(MAN_PAGE) - -install: compile man - cp -f $(BIN) $(PREFIX)/bin - cp -f $(MAN_PAGE) $(PREFIX)/share/man/man1 - -uninstall: - rm -f $(PREFIX)/bin/$(BIN) $(PREFIX)/share/man/man1/$(MAN_PAGE) diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..1eb2838 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,4 @@ +bin_PROGRAMS = rpt +rpt_SOURCES = rpt.c +AM_CFLAGS = -std=c99 -Wall -Wextra -D_GNU_SOURCE +dist_man1_MANS = rpt.1 diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..5461c4a --- /dev/null +++ b/configure.ac @@ -0,0 +1,11 @@ +AC_INIT([repeat], [1.2.0]) +AM_INIT_AUTOMAKE([-Wall -Werror, foreign]) +: ${CFLAGS=""} +AC_PROG_CC +AM_SILENT_RULES([yes]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_FILES([ + Makefile + rpt.1 +]) +AC_OUTPUT diff --git a/rpt.1 b/rpt.1 deleted file mode 100644 index e7d4339..0000000 --- a/rpt.1 +++ /dev/null @@ -1,117 +0,0 @@ -.\" Written by Tristan Riehs. -.\" This file is part of repeat and is licensed under the MIT License. -.TH rpt 1 2023-09-27 - -.SH NAME -rpt \- repeat a shell command - -.SH SYNOPSIS -.B rpt -[ -.B \-n -| -.B \-\-count -.I COUNT -] [ -.B \-f -| -.B \-\-force -] -.I COMMAND - -.B rpt -[ -.B \-h -| -.B \-\-help -] - -.B rpt -[ -.B \-V -| -.B \-\-version -] - -.SH DESCRIPTION -.B rpt -allows you to easily repeat a command a certain number of times. -The command is repeated sequentially. -If stdin is not empty, -it is given to -.IR COMMAND . - -.SH OPTIONS -.BR \-h , -.B \-\-help -.RS -Display help. -.RE - -.BR \-V , -.B \-\-version -.RS -Display version. -.RE - -.BR \-n , -.B \-\-count -.I COUNT -.RS -Repeat -.I COMMAND COUNT -times. -If this flag is not given, -.I COMMAND -is invoked once. -.RE - -.BR \-f , -.B \-\-force -.RS -By default, -.B rpt -stops whenever -.I COMMAND -fails. -If the -.B force -flag is set, -.B rpt -ignores errors. - -.SH "EXIT STATUS" -When a subprocess exit abnormally and the -.B force -flag is not given, -.B rpt -exits with the same status as the subprocess. - -1. Invalid option. - -2. Error while reading -.IR COUNT . -This includes the case where the -.B count -flag is given, -but -.I COUNT -is missing. - -3. -.I COMMAND -not provided. - -4. Other error. - -.SH FILES -None. - -.SH "SEE ALSO" -.BR seq (1) -.BR test (1) - -.SH BUGS - -.SH AUTHOR -Tristan Riehs diff --git a/rpt.1.in b/rpt.1.in new file mode 100644 index 0000000..b7c70ea --- /dev/null +++ b/rpt.1.in @@ -0,0 +1,117 @@ +.\" Written by Tristan Riehs. +.\" This file is part of repeat and is licensed under the MIT License. +.TH repeat @VERSION@ 2023-09-27 + +.SH NAME +repeat \- repeat a shell command + +.SH SYNOPSIS +.B rpt +[ +.B \-n +| +.B \-\-count +.I COUNT +] [ +.B \-f +| +.B \-\-force +] +.I COMMAND + +.B rpt +[ +.B \-h +| +.B \-\-help +] + +.B rpt +[ +.B \-V +| +.B \-\-version +] + +.SH DESCRIPTION +.B rpt +allows you to easily repeat a command a certain number of times. +The command is repeated sequentially. +If stdin is not empty, +it is given to +.IR COMMAND . + +.SH OPTIONS +.BR \-h , +.B \-\-help +.RS +Display help. +.RE + +.BR \-V , +.B \-\-version +.RS +Display version. +.RE + +.BR \-n , +.B \-\-count +.I COUNT +.RS +Repeat +.I COMMAND COUNT +times. +If this flag is not given, +.I COMMAND +is invoked once. +.RE + +.BR \-f , +.B \-\-force +.RS +By default, +.B rpt +stops whenever +.I COMMAND +fails. +If the +.B force +flag is set, +.B rpt +ignores errors. + +.SH "EXIT STATUS" +When a subprocess exit abnormally and the +.B force +flag is not given, +.B rpt +exits with the same status as the subprocess. + +1. Invalid option. + +2. Error while reading +.IR COUNT . +This includes the case where the +.B count +flag is given, +but +.I COUNT +is missing. + +3. +.I COMMAND +not provided. + +4. Other error. + +.SH FILES +None. + +.SH "SEE ALSO" +.BR seq (1) +.BR test (1) + +.SH BUGS + +.SH AUTHOR +Tristan Riehs diff --git a/rpt.c b/rpt.c index d6476ad..46a3de9 100644 --- a/rpt.c +++ b/rpt.c @@ -1,4 +1,4 @@ -#define _GNU_SOURCE /* getopt_long */ +#include "config.h" #include #include @@ -10,10 +10,8 @@ #include #include -#define VERSION "1.1.3" - /* Size of the buffer used to clone stdin. */ -#define BUFSIZE 8000 +#define BUFSIZE (1 << 12) /* Exit status */ #define EXIT_SUCCESS 0 -- cgit v1.2.3