SHTK_BOOL_CHECK(3)

πŸ“¦ version 1.7, in nixos 26.05, nixpkgs unstable

πŸ’– SHTK_BOOL_CHECK(3) πŸ’–

okay so bestie, welcome to the shtk_bool_check page β€” it's a library function from the shtk manual, section 3, and it's literally about turning a string into a boolean. no cap, it's simpler than it sounds. πŸ¦‹

🌸 LIBRARY 🌸

shtk_import bool

like, you gotta import it first, obviously. πŸ’…

✨ SYNOPSIS ✨

shtk_bool_check value [error_message]

πŸŽ€ DESCRIPTION πŸŽ€

so the shtk_bool_check function takes the string value and returns the corresponding boolean value according to shell conventions. that's it. that's the whole vibe. ✨

⭐ RETURN VALUES ⭐

  • shtk_bool_check returns 0 for any value representing truth. these include the strings β€˜yes’ and β€˜true’, including any variations in their capitalization, and the integer number β€˜1’. slay. πŸ‘‘
  • shtk_bool_check returns 1 for any value representing falsehood. these include the strings β€˜no’ and β€˜false’, including any variations in their capitalization, and the integer number β€˜0’. periodt. πŸ’€

🌈 EXAMPLES 🌈

local verbose=no
# Parse flags to see if verbose mode is enabled and set verbose=yes.

if shtk_bool_check "${verbose}"; then
    # Print messages.
fi

like, see how it's used? it's giving "clean little conditional" and we're obsessed. 🫢

πŸ’œ ERRORS πŸ’œ

shtk_bool_check prints the error given in error_message and exits the shell with non-zero if the value does not represent a valid boolean value. and if error_message is not provided, a default message is printed. so yeah β€” pass your message or get the default one, either way you're covered. πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹

πŸ“ HISTORY πŸ“

shtk_bool_check first appeared in shtk 1.4. iconic behavior, honestly. ⭐


and that's the whole page, bestie πŸ’– this beauty comes from Debian, dated November 5, 2014 β€” go forth and boolean-check responsibly. πŸŒΈπŸ’…

πŸ“¦ where this page comes from