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
  • Thanks, Hauke. The elif isn't exactly elif, though, right? It's if...fi ; if [ $? = 0 ] .... Same goes for else... approximation as well, I guess, which is why I deleted my comment before - not only is there no elif there's not even any else..., really, only if.../if !..., I guess. It was your own comments that led me to understand that a little better, I think. So I upvoted your answer, but if you could talk about that angle a little I'd accept it. Unless I'm wrong again... Oh, and just echo true - echo always returns 0. Commented Jun 1, 2014 at 23:12
  • @mikeserv I guess it's an exact elif. &&/|| is always if [ $? -eq 0 ] / if [ $? -ne 0 ] but that doesn't mean that the whole construct is not equivalent to if elif else fi Commented Jun 1, 2014 at 23:32
  • Agreed that the evaluation is equivalent, but the parsing is not, which is what I think I got wrong. Honestly, as I said before, I so seldom use if...fi that I didn't really know, and I thank you for teaching me, but the question is how do they differ? because someone said I was wrong when I said they were equivalent for basically the exact same reasons. So, I guess what I'm asking you to do is to specifically address the question if you would. Commented Jun 1, 2014 at 23:38
  • @mikeserv I have added the explanation from my question comment to the answer. Commented Jun 1, 2014 at 23:56
  • @mikeserv Whatever. As I recently learnt the hard way you can change the accepted answer later. That's probably easier as you are notified about new answers but AFAIR not reminded of accepting one. I would be a bit surprised to see other answers here anyway... Commented Jun 2, 2014 at 0:09