[hackers] [sbase] test: Fix -e, -r, -w and -x || sin
commit 02a55f3fae1ff6a807ac97fe5ba60c3af78913af
Author: sin <sin_AT_2f30.org>
Date: Fri Mar 13 23:44:18 2015 +0000
test: Fix -e, -r, -w and -x
We return 0 when the expression evaluates to true. access() returns
0 on a successful call so check against that.
diff --git a/test.c b/test.c
index 52e2275..1670904 100644
--- a/test.c
+++ b/test.c
_AT_@ -21,10 +21,10 @@ static int unary_u(char *s) { struct stat buf; if ( stat(s, &buf)) return 0; ret
static int unary_n(char *s) { return *s; }
static int unary_z(char *s) { return !*s; }
-static int unary_e(char *s) { return access(s, F_OK); }
-static int unary_r(char *s) { return access(s, R_OK); }
-static int unary_w(char *s) { return access(s, W_OK); }
-static int unary_x(char *s) { return access(s, X_OK); }
+static int unary_e(char *s) { return !access(s, F_OK); }
+static int unary_r(char *s) { return !access(s, R_OK); }
+static int unary_w(char *s) { return !access(s, W_OK); }
+static int unary_x(char *s) { return !access(s, X_OK); }
static int unary_t(char *s) { int fd = enstrtonum(2, s, 0, INT_MAX); return isatty(fd); }
Received on Sat Mar 14 2015 - 00:48:03 CET
This archive was generated by hypermail 2.3.0
: Sat Mar 14 2015 - 01:00:11 CET