Last active
December 26, 2025 00:25
-
-
Save AbeEstrada/1d6b859bcbdc81f8f94ff44258a0cdae to your computer and use it in GitHub Desktop.
Toggle booleans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| if [[ $# -gt 0 ]]; then | |
| input="$1" | |
| else | |
| read -r input _ <<< "$(cat)" | |
| fi | |
| if [[ -z "$input" ]]; then | |
| exit 0 | |
| fi | |
| case "$input" in | |
| "true") echo "false" ;; | |
| "false") echo "true" ;; | |
| "True") echo "False" ;; | |
| "False") echo "True" ;; | |
| "TRUE") echo "FALSE" ;; | |
| "FALSE") echo "TRUE" ;; | |
| "1") echo "0" ;; | |
| "0") echo "1" ;; | |
| "YES") echo "NO" ;; | |
| "NO") echo "YES" ;; | |
| "yes") echo "no" ;; | |
| "no") echo "yes" ;; | |
| *) echo "$input" ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment