Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 3
    Isn't that just because it's negated? Or am I misunderstanding the question? Commented Dec 22, 2021 at 5:32
  • @GordonDavisson the command exits with non-zero so a negation would have resulted in False which is not happening. Commented Dec 22, 2021 at 6:00
  • 3
    "exits with non-zero" is "false" in shell logic. You seem to know the command fails. Negation makes the result true, a success. Commented Dec 22, 2021 at 6:06
  • In the context of an exit status, 0 is truthy and nonzero is falsy. This is the opposite of the convention used in most other contexts, but they're both just conventions; there's no universal rule that 0 must be falsy and non-0 must be truthy. Commented Dec 22, 2021 at 6:23
  • Maybe use the true and false builtins to understand and compare the outcomes of if true ; then echo A ; fi, if ! true ; then echo A ; fi, if false ; then echo A ; fi, and if ! false ; then echo A ; fi, respectively. Commented Dec 22, 2021 at 8:36