mhd_is_file_exec.m4 (1445B)
1 # SPDX-License-Identifier: FSFAP 2 # 3 # SYNOPSIS 4 # 5 # MHD_IS_FILE_EXEC([pathname]) 6 # 7 # DESCRIPTION 8 # 9 # This produces zero shell status code if specified file is executable or 10 # non-zero shell status code if specified file does not exist, is not 11 # executable or is a directory. 12 # On platform, where the system may automatically add executable 13 # suffix (extension) when command is called, this macro checks also 14 # pathname combined with automatic suffix. 15 # To avoid possible word splitting, put parameter in shell quotes. 16 # 17 # Example usage: 18 # 19 # AS_IF([MHD_IS_FILE_EXEC(["/usr/bin/sometool"])], 20 # [AC_MSG_WARNING([/usr/bin/sometool not available])]) 21 # 22 # LICENSE 23 # 24 # Copyright (c) 2026 Karlson2k (Evgeny Grin) <k2k@drgrin.dev> 25 # 26 # Copying and distribution of this file, with or without modification, are 27 # permitted in any medium without royalty provided the copyright notice 28 # and this notice are preserved. This file is offered as-is, without any 29 # warranty. 30 31 #serial 1 32 33 AC_DEFUN([MHD_IS_FILE_EXEC],[dnl 34 AC_REQUIRE([_MHD_IS_FILE_EXEC_BODY])dnl 35 mhd_fn_is_file_exec $1])dnl AC_DEFUN MHD_IS_FILE_EXEC 36 37 38 AC_DEFUN([_MHD_IS_FILE_EXEC_BODY], [m4_divert_text([SHELL_FN],[dnl 39 mhd_fn_is_file_exec () { 40 for mhd_test_exec_ext in "" $ac_executable_extensions ; do 41 AS_IF([AS_EXECUTABLE_P(["${1}${mhd_test_exec_ext}"])],[return 0]) 42 done 43 return 1 44 } # _mhd_fn_print_first_word 45 ])])dnl AC_DEFUN _MHD_PRINT_FIRST_WORD_BODY