← Commit list

0929a129f

Denys Vlasenko
Denys Vlasenko
2024-10-07
SUCCESS Duration: 155s

Subject

test: -x can return 0/1 early if all X bits are the same

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/test.c+10 -10
@@ -654,16 +654,16 @@ static int test_st_mode(struct stat *st, int mode)
enum { ANY_IX = S_IXUSR | S_IXGRP | S_IXOTH };
unsigned euid;
-//TODO if (mode == X_OK) {
-// /* Do we already know with no extra syscalls? */
-// //if (!S_ISREG(st->st_mode))
-// // return 0; /* not a regular file */
-// // ^^^ bash does not check this
-// if ((st->st_mode & ANY_IX) == 0)
-// return 0; /* no one can execute */
-// if ((st->st_mode & ANY_IX) == ANY_IX)
-// return 1; /* anyone can execute */
-// }
+ if (mode == X_OK) {
+ /* Do we already know with no extra syscalls? */
+ //if (!S_ISREG(st->st_mode))
+ // return 0; /* not a regular file */
+ // ^^^ bash 5.2.15 "test -x" does not check this!
+ if ((st->st_mode & ANY_IX) == 0)
+ return 0; /* no one can execute */
+ if ((st->st_mode & ANY_IX) == ANY_IX)
+ return 1; /* anyone can execute */
+ }
euid = get_cached_euid(&groupinfo->euid);
if (euid == 0) {