]> git.corax.cc Git - toolbox/commit
include/opt: Make return values of opt_get() more helpful
authorMatthias Kruk <m@m10k.eu>
Thu, 11 Aug 2022 13:06:36 +0000 (22:06 +0900)
committerMatthias Kruk <m@m10k.eu>
Thu, 11 Aug 2022 13:06:36 +0000 (22:06 +0900)
commit96f78c851f3eef6ef10fed6e0e3a8d139ca94883
tree1870012f4ad587ada14c78cf37fdcc215a694e63
parent6011f6c11aa4f09933219d22bb9d28a3a9b93096
include/opt: Make return values of opt_get() more helpful

The function `opt_get()` returns 0 when an option is valid but was
not set. This makes it impossible to distinguish if the value of
the option is the empty string or it does not have a value at all.
Further, it does not return an error if an invalid option's value
was requested.

This commit fixes the behavior of `opt_get()` so that it returns 0
if an option is valid and has a value (default or user-defined), 1
in case that the option name is invalid, and 2 in case that the
option name is valid but it does not have a value.
include/opt.sh