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*

4
  • Most people just say "$?".  I see no reason to include the { and the }; do you have one? Commented Dec 9, 2018 at 5:42
  • @G-Man It's just my personal preference. Neither the braces nor the quotes around ${?} are really needed in that case AFAIK. Commented Dec 9, 2018 at 6:10
  • Well, quoting shell variables is always recommended; see Security implications of forgetting to quote a variable in bash/POSIX shells, including Steven Penny's answer.   My answer to another question is also relevant. Commented Dec 9, 2018 at 6:27
  • @G-Man Sorry, I didn't express myself correctly. What I meant is that there's no need to quote the ${?} in [[ "${?}" == "0" ]] because word splitting doesn't affect such variable in that specific case. I quoted it anyway because, as Stéphane Chazelas said in the question you linked, "omitting quotes [...] can send a wrong message to beginners: that it may be all right not to quote variables". For the record, I've also made an answer about some subtleties of word splitting. Commented Dec 9, 2018 at 7:30