Last active
June 23, 2023 15:30
-
-
Save HalCanary/1f2fa4c9952b81e19bbc3d0cbf19ad15 to your computer and use it in GitHub Desktop.
[MacOS] get_boolean_value_from_json.sh
This file contains 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
get_boolean_value_from_json() { | |
# Return true if the JSON file exists, the variable is set, and it | |
# evaluates as true in javascript. | |
test -f "$1" && osascript -l 'JavaScript' 2>&1 <<- EOF | |
ObjC.import('stdlib'); | |
$.exit(JSON.parse(\`$(cat "$1")\`).${2} ? 0 : 1); | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment