test-boolean tool
Is there a tool to test strings as boolean values? For instance,
test-booean true, True, TRUE, T, yes, on, 1, succeed, but test-boolean
false, False, FALSE, F, no, off, 0, fail?
I'm writing an init script in which a tool like this would be useful.
I've looked at other init scripts, which simply test if ["$VAR" == true
], but some packages use "true", some use "yes", etc.
If a tool doesn't exist, I think it would be useful in many places and
simple to create. I think there should be a modular tool for this
common task (like the start-stop-daemon or debhelper tools).
One problem I can't resolve is what it should do on test-boolean
notaboolean. Better than resulting in some default behavior (true or
false) on invalid input, would be resulting in an exception. However,
my foreseen application is in a shell script, the if statement of which
(AFAIK) won't result in exceptions (an error is failure is false).
Any suggestions?
Thanks!
Jack
Reply to: