niieani / bash-oo-framework

Bash Infinity is a modern standard library / framework / boilerplate for Bash
https://github.com/niieani/bash-oo-framework/discussions
MIT License
5.57k stars 247 forks source link

Feature: Add exits.sh -- list of exit codes #74

Closed Cj-bc closed 6 years ago

Cj-bc commented 6 years ago

In some shellscript coding guide, I found that we should follow /usr/include/sysexits.h to define exit code. So I added list of those exit codes as variables.

Those values are come from /usr/include/sysexits.h

Cj-bc commented 6 years ago

Perhaps the exit codes could follow a similar convention to color.sh?

I was not sure what prefix should I use... Is it like below?:

Util.exit.OK

( This is better?: util.exit.ok)

the last comment about the "maximum listed value". What does that mean?

Sorry, that's kind of my mistake. It was in sysexits.h. So I left it. Actually, I also don't know what that mean...(perhaps, for reference?) It seems to be better to remove that one

niieani commented 6 years ago

Let's go with something along the lines of: Util.ExitCode.OK Alternatively, if we want to keep simple vars, we can also do underscores instead of dots. Thanks.

Cj-bc commented 6 years ago

As there're not only return but also @return:var, I want to take simple vars so that we can use with both returns. (I'm using both of them. Actually, I'm not sure how to use them properly.) And, if we do this, we can use those exit code numbers in other place, for example, in test code.

So... it'll like this?:

UTIL_EXCODE_OK

usage example:

return $UTIL_EXCODE_OK
@return:val $UTIL_EXCODE_OK
niieani commented 6 years ago

Let's go with upper camelCase, namespaced by underscores: $Util_ExitCode_OK

Cj-bc commented 6 years ago

ok, I'll make change to that style ;)

Cj-bc commented 6 years ago

I'm wondering which is better to use upper camelcase for the codename too( ex: Util_ExitCode_Ok, Util_ExitCode_Dataerror) or not (ex: Util_ExitCode_OK, Util_ExitCode_DATAERROR) I think 2nd one (don't use camelcase) is better, because it is easier to know that it is const. But how do you think?

niieani commented 6 years ago

Yes, I agree! Let's go with uppercase const part.

niieani commented 6 years ago

Thank you!