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*

7
  • Related: What does while read -r line || [[ -n $line ]] mean? Commented Dec 3, 2020 at 18:15
  • 1
    This is one of a number of cases where a command will exit with a nonzero status because of something that isn't really an error (just maybe not a complete success) -- grep when it doesn't find a match, cmp and diff when the files don't match, even (( someexpression )) when the expression evaluates to 0 ("false" in arithmetic context). Commented Dec 3, 2020 at 21:19
  • @GordonDavisson: I consider all of those things to be failures. Commented Dec 3, 2020 at 21:49
  • 1
    @jesse_b That's just it, they're all debatable, depending on people's individual intuitions about what does and doesn't constitute a failure. Other people have certainly been surprised by these. To me, the read behavior does make sense, because it failed to read a complete record (including terminator) from its input. Commented Dec 4, 2020 at 1:32
  • 3
    But these are all reasons why you should not use set -e routinely. Commented Dec 4, 2020 at 15:26