#!/bin/sh
# File: /usr/bin/istruthy
# License: CC-BY-SA-4.0
# Author: bgstack15
# Startdate: 2019-05-01
# Title: istruthy
# Purpose: Accept multiple truthy values for a value
# Package: bgscripts-core
# History:
# Usage:
#    if istruthy "$val"; then echo "it was true" ; fi
# Reference:
#    originally copied out of framework.sh
# Improve:
#    Could rewrite as a C program that recognizes stdin if it is there, or else just interpret argv[0]
# Documentation:
# Dependencies:
#    tr

istruthy() {
   ___f_return=
   case "$( echo "${1}" | tr '[:upper:]' '[:lower:]' )" in
      yes|1|y|true|always|on) ___f_return=true ;;
   esac
   test -n "${___f_return}" ; return $?
   unset ___f_return ;
}
istruthy "${1}"
