[gdal-dev] Standardize gdal-utils scripts return code for "no arguments"
Matt.Wilkie at yukon.ca
Matt.Wilkie at yukon.ca
Mon Apr 4 16:07:08 PDT 2022
Hi folks,
I'm working on "Standardize gdal-utils scripts return codes #5561" for all the scripts in swig/python/gdal-utils. Currently the scripts do not return the same status code for "was run without arguments".
It would be good for the same code meant the same thing across all the scripts in the package. Given that most of the scripts use `1` now, and that this is in line with sys,exit() docs I think it makes sense to make 1 the new standard.
At present we have (return_code, num scripts with that code):
0: 30
1: 56
2: 8
-1: 9
-1 is a special case. In the script code it's written as `return -1` but subprocess.run() captures it as `4294967295`. Another special case is `gdal_auth.py` sample which with no arguments spawns a web authentication page in browser.
Changing the return code will mean anyone who is relying on those in their own scripts or programs will need to adjust. This seems to be a small price for the gain in harmonization across the utilities, to me. Your thoughts?
[0]: https://github.com/OSGeo/gdal/issues/5561
[1]: https://docs.python.org/3/library/sys.html#sys.exit, "Unix programs generally use 2 for command line syntax errors and 1 for all other kind of errors"
Matt Wilkie
Geomatics Developer & Administrator
Environment | Technology, Innovation and Mapping
T 867-667-8133 | Yukon.ca<http://yukon.ca/>
Hours: 08:30-16:30, Mon-Wed: Office, Thu: Remote, Fri: Away.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220404/7b600931/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdal-utils-return-codes.csv
Type: application/octet-stream
Size: 3406 bytes
Desc: gdal-utils-return-codes.csv
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220404/7b600931/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: xx-get-return-codes.py.txt
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220404/7b600931/attachment.txt>
More information about the gdal-dev
mailing list