Skip to content

Commit 51180c0

Browse files
urbanjostLKedward
authored andcommitted
check if name is a directory on backfill instead of depending on system command
1 parent 70ae232 commit 51180c0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fpm/src/fpm/cmd/new.f90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module fpm_cmd_new
22

33
use fpm_command_line, only : fpm_new_settings
44
use fpm_environment, only : run, OS_LINUX, OS_MACOS, OS_WINDOWS
5-
use fpm_filesystem, only : join_path, exists, basename, mkdir
5+
use fpm_filesystem, only : join_path, exists, basename, mkdir, is_dir
66
use,intrinsic :: iso_fortran_env, only : stderr=>error_unit
77
implicit none
88
private
@@ -20,8 +20,11 @@ subroutine cmd_new(settings) ! --with-executable F --with-test F '
2020
write(stderr,'(*(g0,1x))')'fpm::new<ERROR>',settings%name,'already exists.'
2121
write(stderr,'(*(g0,1x))')' perhaps you wanted to add --backfill ?'
2222
return
23-
elseif(exists(settings%name) .and. settings%backfill )then
23+
elseif(is_dir(settings%name) .and. settings%backfill )then
2424
write(*,'(*(g0))')'backfilling ',settings%name
25+
elseif(exists(settings%name) )then
26+
write(stderr,'(*(g0,1x))')'fpm::new<ERROR>',settings%name,'already exists and is not a directory.'
27+
return
2528
else
2629
call mkdir(settings%name) ! make new directory
2730
endif

0 commit comments

Comments
 (0)