Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#4542 closed defect (fixed)

gdal_merge.py globbing breaks use of non-simple-files

Reported by: warmerdam Owned by: warmerdam
Priority: normal Milestone:
Component: Utilities Version: unspecified
Severity: normal Keywords: gdal_merge.py
Cc:

Description

An attempt to do something like:

gdal_merge -o /tmp/a.tif HDF4_EOS:EOS_GRID:"/tmp/file.hdf":MOD_Grid_Seaice_1km:Ice_Surface_Temperature_Spatial_QA

fails because of the globbing in this code in gdal_merge.py fails:

            # Expand any possible wildcards from command line arguments
            f = glob.glob( arg )
            if len(f) == 0:
                print('File not found: "%s"' % (str( arg )))
            names += f # append 1 or more files

Change History (3)

comment:1 Changed 9 years ago by warmerdam

Resolution: fixed
Status: newclosed

This was an old issue - see (#2783).

all globbing changes backed out in trunk (r24064), 1.9 (r24063) and 1.8 (r24062). evil evil stuff.

If it is going to be reintroduced it needs to be respectful of non-simple files and likely should be windows only.

comment:2 Changed 9 years ago by Even Rouault

Or perhaps something like this that uses glob only if there's a '*' or a '?' in the string ?

Index: gdal/swig/python/scripts/gdalident.py
===================================================================
--- gdal/swig/python/scripts/gdalident.py	(révision 24068)
+++ gdal/swig/python/scripts/gdalident.py	(copie de travail)
@@ -36,6 +36,7 @@
 import sys
 import stat
 import os
+import glob
 
 # =============================================================================
 # 	Usage()
@@ -97,7 +98,14 @@
         report_failure = 1
 
     else:
-        files.append(arg)
+        if arg.find('*') != -1 or arg.find('?') != -1:
+            # Expand any possible wildcards from command line arguments
+            f = glob.glob( arg )
+            if len(f) == 0:
+                print('File not found: "%s"' % ( str( arg ) ))
+            files += f # append 1 or more files
+        else:
+            files.append(arg)
 
     i = i + 1

comment:3 Changed 9 years ago by warmerdam

A few notes: 1) It is legal to have ? and * in dataset names. 2) If we do something it should not be (IMHO) be idiosyncratic to gdalident.py and gdal_merge.py. 3) I don't see any purpose for it other than on windows, so why not limit it to there?

Note: See TracTickets for help on using tickets.