Skip to content

Commit cdb7d7d

Browse files
committed
always enclose filename in quotes in execute function if it isn't already
also added an extra error check if the filename is blank
1 parent d9ded3f commit cdb7d7d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/pyplot_module.F90

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,12 @@ subroutine execute(me, pyfile, istat, python)
13971397
file = trim(pyfile) !use the user-specified name
13981398
end if
13991399

1400+
if (file == '') then
1401+
if (present(istat)) istat = -1
1402+
write(error_unit,'(A)') 'Error: filename is blank.'
1403+
return
1404+
end if
1405+
14001406
!open the file:
14011407
open(newunit=iunit, file=file, status='REPLACE', iostat=iostat)
14021408
if (iostat/=0) then
@@ -1423,8 +1429,8 @@ subroutine execute(me, pyfile, istat, python)
14231429
end if
14241430

14251431
!run the file using python:
1426-
if (index(file,' ')>0) then
1427-
! space in path, probably should enclose in quotes
1432+
if (file(1:1)/='"') then
1433+
! if not already in quotes, should enclose in quotes
14281434
call execute_command_line(python_//' "'//file//'"')
14291435
else
14301436
call execute_command_line(python_//' '//file)

0 commit comments

Comments
 (0)