Determine the executable to use when spawning the child watcher.
Precedence:
1. Explicit exe0 argument
2. Environment FPM_WATCH_SELF
3. argv[0]
4. Fallback "fpm-watch"
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | exe0 |
function choose_self_exe(exe0) result(exe) character(len=*), intent(in) :: exe0 character(len=:), allocatable :: exe character(len=2048) :: buf integer :: n, stat character(len=:), allocatable :: a0 if (len_trim(exe0) > 0) then exe = trim(exe0) return end if buf = "" n = 0 stat = 0 call get_environment_variable("FPM_WATCH_SELF", buf, length=n, status=stat) if (stat == 0 .and. n > 0) then exe = trim(buf(1:n)) return end if a0 = get_arg(0) if (len_trim(a0) > 0) then exe = trim(a0) return end if exe = "fpm-watch" end function choose_self_exe