aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-02-22 12:54:48 +0100
committerMattias Andrée <m@maandree.se>2026-02-22 12:54:48 +0100
commit6a1923f36ffef608e99dfc217e83f10d2741a909 (patch)
treeffb18a2acd1b37f54e817f4ca91fac7b057cd0db
parentUpdate e-mail (diff)
downloadxtest-2.1.3.tar.gz
xtest-2.1.3.tar.bz2
xtest-2.1.3.tar.xz
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--Makefile2
-rw-r--r--README12
-rw-r--r--config.mk4
-rw-r--r--xtest.112
-rw-r--r--xtest.c2
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); }