I finally understood/discovered why I never got to using bash's (and also zsh's) brace expansion range properly: the syntax is {1..10} instead of what I assumed to be an ellipsis, i.e. {1...10}.

May I know why two dots was chosen over three dots? Usage of ellipsis in computer programming is common and well-understood as indicated by the (Wikipedia) link, which is why this piqued my curiosity.

  • 3
    Apparently, it originated in Perl... – jasonwryan Mar 11 '15 at 6:05
  • 3
    The use of n1..n2 in programming to denote a range from n1 to n2 predates Perl by quite a bit. See this Pascal User Manual from 1970, section 6.1.2 on page 17. – Adaephon Mar 11 '15 at 7:57
  • 1
    Hey commenters, feel free to turn your comments into answers...? :) – h.j.k. Mar 11 '15 at 8:20
  • I have a vague recollection that some languages now even use .. vs. ... for including the right endpoint or not, but I may be wrong. (Ruby? Was that Ruby?) – Ulrich Schwarz Mar 11 '15 at 10:10
  • 3
    @slm I'm going to have to disagree on the close reason here. History questions about how something came to be are not really opinion based. Comments have already hinted the answer is just a matter of history and in spite of the "why" in the title this could be answered quite solidly. – Caleb Mar 11 '15 at 14:22

(posting as community wiki instead, thanks to the contributions in the comments)

It is mentioned in the book From Bash to Z Shell (Chapter 8, Page 186, "Generating Numbers with Braces") that this syntax is borrowed from Perl.

In addition, it is also suggested that Pascal had the .. range notation dating back as far back as 1970 (emphasis mine) ("The Programming Language Pascal", Section 6.1.2, Page 17 of the linked PDF).

In conclusion, even the Wikipedia link from the question stated some examples where .. is used. The assumption that an ellipsis is strictly defined as a sequence of three dots, as it is as a punctuation mark, does not hold true here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.