bash: ending statements



~1 min read


103 words

I was reviewing a bash script that I use recently and noticed the esac keyword. I hadn’t noticed it before, so I started looking into it a bit more and found that it signifies the end of a case statement.

This “reverse word” technique to mark the end of a code block apparently has its roots in the ALGOL68 language’s expressions

  • if is closed with fi
  • case is closed with esac
  • do is od, but in bash it has been replaced with done, likely to avoid conflicting with octal dump. Similarly done is used for for, while, and until loops.

Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!