0

How can parse the exit code from a command snyk where an exit code is 3 but $?'s value is 0

I have a simple bash script:

#!/bin/bash
bin test -d --json --all-projects | tee >> file.json

ret=$?
echo "ret was $ret"

if [ $ret -eq 0 ]; then
echo "No vulns"

elif [ $ret -eq 1 ]; then
echo "got vulns"

elif [ $ret -eq 2 ]; then
echo "not all dependencies"

elif [ $ret -eq 3 ]; then
echo "dont have all req manifest"

else
echo "I got nothing"

fi

This is outputting:

ret was 0
No vulns

How can I parse this Snyk Exit code: 3 and modify my final elif block instead to hit the final elif [ $ret -eq 3 ]; then block?

Thanks

Jshee
  • 2,620
  • 6
  • 44
  • 60

0 Answers0