Skip to content

Commit 80d7f3f

Browse files
committed
return program's exit code
1 parent b364bd8 commit 80d7f3f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/fpm.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ subroutine cmd_run(settings,test)
441441
type(string_t), allocatable :: executables(:)
442442
type(build_target_t), pointer :: exe_target
443443
type(srcfile_t), pointer :: exe_source
444-
integer :: run_scope
444+
integer :: run_scope,firsterror
445445
integer, allocatable :: stat(:)
446446
character(len=:),allocatable :: line
447447
logical :: toomany
@@ -586,10 +586,12 @@ subroutine cmd_run(settings,test)
586586
if (any(stat /= 0)) then
587587
do i=1,size(stat)
588588
if (stat(i) /= 0) then
589-
write(stderr,'(*(g0:,1x))') '<ERROR> Execution failed for object "',basename(executables(i)%s),'"'
589+
write(stderr,'(*(g0:,1x))') '<ERROR> Execution for object "',basename(executables(i)%s),&
590+
'" returned exit code ',stat(i)
590591
end if
591592
end do
592-
call fpm_stop(1,'*cmd_run*:stopping due to failed executions')
593+
firsterror = findloc(stat/=0,value=.true.,dim=1)
594+
call fpm_stop(stat(firsterror),'*cmd_run*:stopping due to failed executions')
593595
end if
594596

595597
endif

src/fpm_filesystem.F90

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,10 +924,8 @@ subroutine run(cmd,echo,exitstat,verbose,redirect)
924924

925925
if (present(exitstat)) then
926926
exitstat = stat
927-
else
928-
if (stat /= 0) then
929-
call fpm_stop(1,'*run*:Command failed')
930-
end if
927+
elseif (stat /= 0) then
928+
call fpm_stop(stat,'*run*: Command '//cmd//redirect_str//' returned a non-zero status code')
931929
end if
932930

933931
end subroutine run

0 commit comments

Comments
 (0)