-
-
Save alxmal/63c0bc73cd7bf8ade27150b841ea1b29 to your computer and use it in GitHub Desktop.
Revisions
-
dishbreak revised this gist
Nov 2, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ set -e # Function that checks if a given executable is on the path. If it isn't, prints an install message and exits. # Usage: check_binary EXECUTABLE_NAME INSTALL_MESSAGE check_binary() { if ! which "$1" > /dev/null; then # Using a subshell to redirect output to stderr. It's cleaner this way and will play nice with other redirects. # https://stackoverflow.com/a/23550347/225905 ( >&2 echo "$2" ) -
dishbreak created this gist
Nov 2, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/bin/bash # Exit on the first command that returns a nonzero code. set -e # Function that checks if a given executable is on the path. If it isn't, prints an install message and exits. # Usage: check_binary EXECUTABLE_NAME INSTALL_MESSAGE check_binary() { if ! which "$1"; then # Using a subshell to redirect output to stderr. It's cleaner this way and will play nice with other redirects. # https://stackoverflow.com/a/23550347/225905 ( >&2 echo "$2" ) # Exit with a nonzero code so that the caller knows the script failed. exit 1 fi } check_binary "jq" "$(cat <<EOF You will need jq to run this script. Install it using your package manager. E.g. for homebrew: brew install jq EOF )" # a dumb command that uses jq in order to provide a SSCCE snippet # http://sscce.org/ jq -r ".message" <<EOF {"message": "hello from jq!"} EOF