summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2023-07-17 18:50:03 +0100
committerPhil Jones <philj56@gmail.com>2023-07-17 18:50:03 +0100
commite918dd42ecd6ebdfa2a6d7726bc6e4dafc654f31 (patch)
tree352b641509440e85790458f2f329128d8370544a /src
parent9a808337312efdf607e33c351fd72e7a95821f12 (diff)
Use `access()` to check execute permissions.
This is the correct way to check if we have execute permissions for a file (rather than checking `S_IXUSR`), and it isn't any slower. Should result in very few differences (on my system, only `cupsd` disappears from the list with this change).
Diffstat (limited to 'src')
-rw-r--r--src/compgen.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compgen.c b/src/compgen.c
index af8050d..27368e8 100644
--- a/src/compgen.c
+++ b/src/compgen.c
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#include <unistd.h>
#include "compgen.h"
#include "history.h"
#include "log.h"
@@ -192,7 +193,7 @@ char *compgen()
if (fstatat(fd, d->d_name, &sb, 0) == -1) {
continue;
}
- if (!(sb.st_mode & S_IXUSR)) {
+ if (faccessat(fd, d->d_name, X_OK, 0) == -1) {
continue;
}
if (!S_ISREG(sb.st_mode)) {