t: add a function to check executable bit

In line with our other helper functions for paths, let's add a function
to check whether a path is executable, and if not, print a suitable
error message.  Document this function, and note that it must only be
used under the POSIXPERM prerequisite, since it doesn't otherwise work
on Windows.

Signed-off-by: brian m. carlson <bk2204@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson
2023-06-27 16:18:56 +00:00
committed by Junio C Hamano
parent 4db16f58c7
commit d6546af75c
2 changed files with 15 additions and 0 deletions

View File

@ -901,6 +901,15 @@ test_path_is_symlink () {
fi
}
test_path_is_executable () {
test "$#" -ne 1 && BUG "1 param"
if ! test -x "$1"
then
echo "$1 is not executable"
false
fi
}
# Check if the directory exists and is empty as expected, barf otherwise.
test_dir_is_empty () {
test "$#" -ne 1 && BUG "1 param"