Gmt info: reporting of mismatch of actual and expected fields

Given files:

cat<<eof > file1
2 4
6 7
2 8
eof

cat<<eof > file2
2 4
trash
6 7
2 8
eof

cated with line numbers::

$ cat -n file1 file2
     1	2 4
     2	6 7
     3	2 8
     4	2 4
     5	trash
     6	6 7
     7	2 8

Case 1: cating to gmt info reports bad content on line 5. This seems reasonable (ref. the cated output above):

$ cat file1 file2 | gmt info
gmtinfo [WARNING]: Mismatch between actual (1) and expected (2) fields near line 5 in file <Standard Input>

Case 2: Specifying the filenames to gmt info reports bad content on line 6:

$ gmt info file1 file2
gmtinfo [WARNING]: Mismatch between actual (1) and expected (2) fields near line 6 in file file2
  • Q1: Why does the line number of reported mismatch differ between case 1 and 2?

  • Q2: In Case 2, gmt info reports the correct file name, but the line number refers to the combined/concatenated files (“logically correct”).

    This does not really help, since you have to open the file where the error occurs, and fix it.
    The line number where the error is in file2, is line no. 2.

    Isn’t it this number that should reported?

    According to gmt info, I should open file2 and take a look at line number 6, but this line does not exist.

Addressed by this git PR

1 Like

Thanks Paul!

PS: I ran into this issue while using xyz2grd. I created an example with gmtinfo for simplicity. I assume that the fix applies to all modules using this machinery. Sorry for not being clear about this.