From 6a1923f36ffef608e99dfc217e83f10d2741a909 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 22 Feb 2026 12:54:48 +0100 Subject: m fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 2 +- README | 12 ++++++------ config.mk | 4 +++- xtest.1 | 12 ++++++------ xtest.c | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index c93e06d..5c0d75e 100644 --- a/Makefile +++ b/Makefile @@ -38,4 +38,4 @@ clean: .SUFFIXES: .SUFFIXES: .o .c -.PHONY: all install uninstall clean +.PHONY: all check install uninstall clean diff --git a/README b/README index 136417b..9ac035c 100644 --- a/README +++ b/README @@ -6,10 +6,10 @@ SYNOPSIS DESCRIPTION xtest tests the file types and permissions of each specified - file, if not file has been specified, a list file is read + file; if no file has been specified, a list file is read from stdin. - Each file that pass at least one of the tests is printed to + Each file that passes at least one of the tests is printed to stdout. OPTIONS @@ -29,7 +29,7 @@ OPTIONS setuid(4) [-u] | read(4) [-r] | write(2) [-w] | execute(1) [-x]) permissions. - -t Input is an file descriptor and is associated with a + -t Input is a file descriptor and is associated with a terminal. +e File does not exist. @@ -41,7 +41,7 @@ OPTIONS [+b] | character special [+c]). +k | +g | +u | +r | +w | +x - File does not exist or does not has (sticky(1) [+k] | + File does not exist or does not have (sticky(1) [+k] | setgid(2) [+g] | setuid(4) [+u] | read(4) [+r] | write(2) [+w] | execute(1) [+x]) permissions. @@ -52,9 +52,9 @@ RATIONALE +-flags are included because it is too cumbersome to use comm(1). - Only one test need to pass because this allows the user to + Only one test needs to pass because this allows the user to represent the required condition in conjunctive normal form - by pipe together multiple instances of xtest for conjunction. + by piping together multiple instances of xtest for conjunction. Disjunctive normal form is not as simple. SEE ALSO diff --git a/config.mk b/config.mk index 21f9f6f..5c4b041 100644 --- a/config.mk +++ b/config.mk @@ -1,6 +1,8 @@ PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man -CFLAGS = -std=c99 -Wall -pedantic -O2 +CC = c99 + CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE +CFLAGS = LDFLAGS = -s diff --git a/xtest.1 b/xtest.1 index 1f25f72..e12d397 100644 --- a/xtest.1 +++ b/xtest.1 @@ -12,10 +12,10 @@ .Sh DESCRIPTION .Nm tests the file types and permissions of each specified -file, if not file has been specified, a list file is read +file; if no file has been specified, a list file is read from stdin. .Pp -Each file that pass at least one of the tests is printed to +Each file that passes at least one of the tests is printed to stdout. .Sh OPTIONS .Bl -tag -width Ds @@ -62,7 +62,7 @@ File exists and has .Op Fl x ) permissions. .It Fl t -Input is an file descriptor and is associated with a terminal. +Input is a file descriptor and is associated with a terminal. .It \fB+e\fP File does not exist .It \fB+f\fP | \fB+d\fP | \fB+p\fP | \fB+hL\fP | \fB+S\fP | \fB+s\fP | \fB+b\fP | \fB+c\fP @@ -83,7 +83,7 @@ File does not exist or is not a (regular file | character special .Op \fB+c\fP ) . .It \fB+k\fP | \fB+g\fP | \fB+u\fP | \fB+r\fP | \fB+w\fP | \fB+x\fP -File does not exist or does not has +File does not exist or does not have .Xr ( sticky 1 .Op \fB+k\fP | @@ -109,9 +109,9 @@ Input is not a file descriptor or is not associated with a terminal. \fB+\fP-flags are included because it is too cumbersome to use .Xr comm 1 . .Pp -Only one test need to pass because this allows the user to +Only one test needs to pass because this allows the user to represent the required condition in conjunctive normal form -by pipe together multiple instances of +by piping together multiple instances of .Nm xtest for conjunction. Disjunctive normal form is not as simple. .Sh SEE ALSO diff --git a/xtest.c b/xtest.c index 7a45089..895ced3 100644 --- a/xtest.c +++ b/xtest.c @@ -24,7 +24,7 @@ static int test_h(char *s) { struct stat buf; if (lstat(s, &buf)) return 0; retu static int test_k(char *s) { struct stat buf; if ( stat(s, &buf)) return 0; return S_ISVTX & buf.st_mode ; } static int test_p(char *s) { struct stat buf; if ( stat(s, &buf)) return 0; return S_ISFIFO (buf.st_mode); } static int test_S(char *s) { struct stat buf; if ( stat(s, &buf)) return 0; return S_ISSOCK (buf.st_mode); } -static int test_s(char *s) { struct stat buf; if ( stat(s, &buf)) return 0; return buf.st_size ; } +static int test_s(char *s) { struct stat buf; if ( stat(s, &buf)) return 0; return !!buf.st_size ; } static int test_u(char *s) { struct stat buf; if ( stat(s, &buf)) return 0; return S_ISUID & buf.st_mode ; } static int test_e(char *s) { return !faccessat(AT_FDCWD, s, F_OK, AT_EACCESS); } -- cgit v1.2.3-70-g09d2