I don't see sips to emit error codes at all:
$ sips main.rb -g all
/Users/nakilon/main.rb
Error: Error querying file
$ echo $?
0
$ sips main.rb -g allasdasda
/Users/nakilon/main.rb
Error: Error querying file
$ echo $?
0
How do I know if it has failed?
sips
(as you have tagged it) is a macOS program for processing images at the command-line which is probably not going to want to do much with a Ruby program text/script.If you really do mean to use
sips
and with a Ruby file, you need to put the flags before the filename: