oz / tz

🌐 A time zone helper
GNU General Public License v3.0
849 stars 33 forks source link

Exit code for empty `-list` search #70

Open jnd-au opened 1 week ago

jnd-au commented 1 week ago

Currently, the tz -list <value> option can be used to search for timezone names and abbreviations. However, if no names are found, then tz simple prints nothing (not even an error message) and exits with ‘success’ status code 0. This is contrary to the UNIX convention of non-zero (error code) exit. For example, most search utilities (e.g. grep) will return 1 if there are no matches. It could be good if tz follows this convention, so that the exit code of tz -list <value> is the same as the exit code of tz -list | grep <value>. This would also ensure tz exits non-zero if tz’s internal tz list is empty for some reason. Also, given that this is a user mode option, it could also be good to print an error message to stderr.