diff options
| author | Mattias Andrée <m@maandree.se> | 2026-02-22 12:54:48 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-02-22 12:54:48 +0100 |
| commit | 6a1923f36ffef608e99dfc217e83f10d2741a909 (patch) | |
| tree | ffb18a2acd1b37f54e817f4ca91fac7b057cd0db | |
| parent | Update e-mail (diff) | |
| download | xtest-6a1923f36ffef608e99dfc217e83f10d2741a909.tar.gz xtest-6a1923f36ffef608e99dfc217e83f10d2741a909.tar.bz2 xtest-6a1923f36ffef608e99dfc217e83f10d2741a909.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | README | 12 | ||||
| -rw-r--r-- | config.mk | 4 | ||||
| -rw-r--r-- | xtest.1 | 12 | ||||
| -rw-r--r-- | xtest.c | 2 |
5 files changed, 17 insertions, 15 deletions
@@ -38,4 +38,4 @@ clean: .SUFFIXES: .SUFFIXES: .o .c -.PHONY: all install uninstall clean +.PHONY: all check install uninstall clean @@ -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 @@ -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 @@ -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 @@ -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); } |
