diff options
author | Laurence Kedward <laurence.kedward@bristol.ac.uk> | 2021-06-23 11:03:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 11:03:14 +0100 |
commit | 041178013ac9cbcbd64e22e06a2b30737e3b4658 (patch) | |
tree | 8b1d81d057f5e240bd35a46e72f2528426d1a466 /src/fpm_environment.f90 | |
parent | d693d685d033c0da9c24686d61fdf6ede2caa7e4 (diff) | |
parent | faae6a41552b020b683bc936a7dd5ee1723b2b0d (diff) | |
download | fpm-041178013ac9cbcbd64e22e06a2b30737e3b4658.tar.gz fpm-041178013ac9cbcbd64e22e06a2b30737e3b4658.zip |
Merge pull request #491 from LKedward/backend-grace
Catch execute_command_line errors and print useful messages
Diffstat (limited to 'src/fpm_environment.f90')
-rw-r--r-- | src/fpm_environment.f90 | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/fpm_environment.f90 b/src/fpm_environment.f90 index a3c073f..cf76250 100644 --- a/src/fpm_environment.f90 +++ b/src/fpm_environment.f90 @@ -137,9 +137,10 @@ contains end function os_is_unix !> echo command string and pass it to the system for execution - subroutine run(cmd,echo) + subroutine run(cmd,echo,exitstat) character(len=*), intent(in) :: cmd logical,intent(in),optional :: echo + integer, intent(out),optional :: exitstat logical :: echo_local integer :: stat @@ -151,10 +152,16 @@ contains if(echo_local) print *, '+ ', cmd call execute_command_line(cmd, exitstat=stat) - if (stat /= 0) then - print *, 'Command failed' - error stop + + if (present(exitstat)) then + exitstat = stat + else + if (stat /= 0) then + print *, 'Command failed' + error stop + end if end if + end subroutine run !> get named environment variable value. It it is blank or |