path: Improve $PATH search directory case
authorChris Down <chris@chrisdown.name>
Wed, 26 Aug 2020 17:49:27 +0000 (18:49 +0100)
committerMichael Biebl <biebl@debian.org>
Sat, 29 Aug 2020 16:39:32 +0000 (17:39 +0100)
commit8395180a7e0bb2d097482d96fccb1c09de197372
treeb2639e426a6d478272fcc7972a55511064271af6
parenta43d638c3f2e01d9c22bd7ae84e6146ec14e08d9
path: Improve $PATH search directory case

Previously:

1. last_error wouldn't be updated with errors from is_dir;
2. We'd always issue a stat(), even for binaries without execute;
3. We used stat() instead of access(), which is cheaper.

This change avoids all of those, by only checking inside X_OK-positive
case whether access() works on the path with an extra slash appended.
Thanks to Lennart for the suggestion.

(cherry picked from commit 33e1a5d8d3f792e1d98377fe439e123231032ec7)

Gbp-Pq: Name path-Improve-PATH-search-directory-case.patch
src/basic/path-util.c