Last active
          September 4, 2020 15:04 
        
      - 
      
 - 
        
Save skojin/a24cd8e6384583782afe0e36cc2bbdf4 to your computer and use it in GitHub Desktop.  
    test input with jq, if ok then show input, otherwise exit with non 0 exit code
  
        
  
    
      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
    
  
  
    
  | #!/bin/sh | |
| # test input with jq, if ok then show input, otherwise exit with non 0 exit code | |
| # echo '{"success": true}' | jq -e '.success | select(. == true)' # => {"success": true} | |
| # echo '{"success": false}' | jq -e '.success | select(. == true)' # => exit code non 0 | |
| input=`cat`; | |
| if echo "$input" | jq -e "$1" > /dev/null ; then | |
| echo "$input" | |
| else | |
| exit $? | |
| fi | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment