I want to put an error checking solution to my script, it looks like this:
! [ `echo $?` != 0 ] || echo "omg, st went wrong, CTRL+C? `read`"
My goal is when this line runs it check the "$?" - if it's not 0 then it says "omg, st went wrong, CTRL+C?" then it waits for enter, or CTRL+C from the user. But my one-liner isn't working, because it waits for an enter before printing the "omg, st went wrong, CTRL+C?" text. Can someone help me what am I missing?
Thanks.
UPDATE: it would be better to do it after the command st like in: Check that there was an error one-liner in script
the "bad command" is "uname -k" the good command is "echo hi" - the uname gives non zero exit code, the echo gives 0