Return the program invoked by a command line (its first shell token), OS-aware. Uses fpm’s shell lexer so quoted paths stay intact and trailing arguments (e.g. a wrapper’s “mpifort -fc=gfortran”) are dropped. Returns ‘’ if empty.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | cmd |
function command_program(cmd) result(prog) character(*), intent(in) :: cmd character(:), allocatable :: prog character(len=:), allocatable :: tokens(:) prog = '' if (os_is_unix()) then tokens = sh_split(cmd) ! POSIX lexer else tokens = ms_split(cmd, ucrt=.true.) ! Windows lexer end if ! The program is always reliably the first token. if (allocated(tokens)) then if (size(tokens) > 0) prog = trim(adjustl(tokens(1))) end if end function command_program