How can exit codes of a program be inverted through Bash such that when it exits with a 0 exit code, I get a 1, otherwise a 0?
Asked
Active
Viewed 1,351 times
0
-
`0 exit code, I get a 1` --> meaning you want to make a command fail when it passes. Remember `0` in shell's context is successful execution. You need to provide more details – Inian Apr 13 '18 at 09:57
-
@Inian Exactly. I want to make a command fail when it passes and pass when it fails. – ayushgp Apr 13 '18 at 09:58
-
Kind of like a not operation on the exit code – ayushgp Apr 13 '18 at 09:58
-
2TL;DR: Use !. `! my_program`. – L3viathan Apr 13 '18 at 10:01