bash-oo-framework
bash-oo-framework copied to clipboard
False boolean not working
The following error occurred
boolean trueVar=true $var:trueVar toString #true
boolean falseVar=false $var:falseVar toString #UNCAUGHT EXCEPTION: toString
Is it a bug? Or is my implementation incorrect?
Actually toString of false boolean is implemented so that it behaves like false:
https://github.com/niieani/bash-oo-framework/blob/0276ffad26cabd5ce29f18b4ca87fbc01bc630ab/lib/TypePrimitives/boolean.sh#L15
The return code of false is 1, which means it's treated like an exception.
Probably might sense to change how boolean toString works cause it's unintuitive right now. I don't remember what was the reason I did it like this. I think it's so that invoking that variable would behave similarly to invoking true or false and so that one could use this in comparisons or logic.