sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit c23616555bf2830d478508f14a8d6f2504cda835
parent 11c078d116b828732716223101f6e72e1bb52e34
Author: sin <sin@2f30.org>
Date:   Mon, 11 Nov 2013 11:37:07 +0000

Add support for -k (checking sticky bit) to test(1)

Diffstat:
Mtest.1 | 3+++
Mtest.c | 6++++--
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/test.1 b/test.1 @@ -29,6 +29,9 @@ ILE exists and is a regular file .B \-g FILE FILE exists and is set-group-ID .TP +.B \-k FILE +FILE exists and its sticky bit is set +.TP .B \-h FILE FILE exists and is a symbolic link (same as -L) .TP diff --git a/test.c b/test.c @@ -57,7 +57,7 @@ unary(const char *op, const char *arg) usage(); switch(op[1]) { case 'b': case 'c': case 'd': case 'f': case 'g': - case 'p': case 'S': case 's': case 'u': + case 'k': case 'p': case 'S': case 's': case 'u': if((r = stat(arg, &st)) == -1) return false; /* -e */ switch(op[1]) { @@ -71,6 +71,8 @@ unary(const char *op, const char *arg) return S_ISREG(st.st_mode); case 'g': return st.st_mode & S_ISGID; + case 'k': + return st.st_mode & S_ISVTX; case 'p': return S_ISFIFO(st.st_mode); case 'S': @@ -153,5 +155,5 @@ usage(void) const char *ket = (*argv0 == '[') ? " ]" : ""; eprintf("usage: %s string%s\n" - " %s [!] [-bcdefghLnprSstuwxz] string%s\n", argv0, ket, argv0, ket); + " %s [!] [-bcdefgkhLnprSstuwxz] string%s\n", argv0, ket, argv0, ket); }