Skip to content

Commit 76f87eb

Browse files
committed
correct basename(3f) function and subsequently fix --list option
The --list option was incorrectly trimming pathnames when suffix=.false. was present, and the meaning of the --list option has changed from originally being an option to display the full pathnames of targets to displaying a table of matching target basenames. Since the --runner command can be used to display the full pathnames and the runner command defaults to an "echo" command the pathnames can still easily be generated, but an example was added to reflect that. As the help text needed editing anyway, changed some whitespace to conform to the requirements of the txt2man(1) utility, to facilitate easily generating man-pages and HTML versions of the help text.
1 parent 9fc759a commit 76f87eb

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/fpm.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ subroutine cmd_build(settings)
287287
call build_package(targets,model)
288288
endif
289289

290-
end subroutine
290+
end subroutine cmd_build
291291

292292
subroutine cmd_run(settings,test)
293293
class(fpm_run_settings), intent(in) :: settings

src/fpm_command_line.f90

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ subroutine set_help()
864864
help_text_flag, &
865865
' --runner CMD A command to prefix the program execution paths with. ', &
866866
' see "fpm help runner" for further details. ', &
867-
' --list list pathname of candidates instead of running them. Note ', &
867+
' --list list basenames of candidates instead of running them. Note ', &
868868
' out-of-date candidates will still be rebuilt before being ', &
869869
' listed. ', &
870870
' -- ARGS optional arguments to pass to the program(s). The same ', &
@@ -876,7 +876,9 @@ subroutine set_help()
876876
' fpm(1) - run or display project applications: ', &
877877
' ', &
878878
' fpm run # run a target when only one exists or list targets ', &
879-
' fpm run --list # list all targets, running nothing. ', &
879+
' fpm run --list # list basename of all targets, running nothing. ', &
880+
' fpm run "demo*" --list # list target basenames starting with "demo*".', &
881+
' fpm run "psi*" --runner # list target pathnames starting with "psi*".', &
880882
' fpm run --all # run all targets, no matter how many there are. ', &
881883
' ', &
882884
' # run default program built or to be built with the compiler command ', &
@@ -885,7 +887,7 @@ subroutine set_help()
885887
' fpm run --compiler f90 ', &
886888
' ', &
887889
' # run example programs instead of the application programs. ', &
888-
' fpm run --example ''*'' ', &
890+
' fpm run --example "*" ', &
889891
' ', &
890892
' # run a specific program and pass arguments to the command ', &
891893
' fpm run myprog -- -x 10 -y 20 --title "my title line" ', &
@@ -1110,7 +1112,8 @@ subroutine set_help()
11101112
help_text_flag, &
11111113
' --runner CMD A command to prefix the program execution paths with. ', &
11121114
' see "fpm help runner" for further details. ', &
1113-
' --list list candidates instead of building or running them ', &
1115+
' --list list candidate basenames instead of running them. Note they', &
1116+
' --list will still be built if not currently up to date. ', &
11141117
' -- ARGS optional arguments to pass to the test program(s). ', &
11151118
' The same arguments are passed to all test names ', &
11161119
' specified. ', &

src/fpm_filesystem.F90

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,18 @@ function basename(path,suffix) result (base)
9494
with_suffix = suffix
9595
end if
9696

97-
if (with_suffix) then
98-
call split(path,file_parts,delimiters='\/')
99-
if(size(file_parts).gt.0)then
100-
base = trim(file_parts(size(file_parts)))
101-
else
102-
base = ''
103-
endif
97+
call split(path,file_parts,delimiters='\/')
98+
if(size(file_parts).gt.0)then
99+
base = trim(file_parts(size(file_parts)))
104100
else
105-
call split(path,file_parts,delimiters='\/.')
101+
base = ''
102+
endif
103+
if(.not.with_suffix)then
104+
call split(base,file_parts,delimiters='.')
106105
if(size(file_parts).ge.2)then
107106
base = trim(file_parts(size(file_parts)-1))
108-
else
109-
base = ''
110107
endif
111-
end if
108+
endif
112109

113110
end function basename
114111

0 commit comments

Comments
 (0)