9

I am wondering after seeing this question why the . symbol was chosen to represent the dot command?

I am not able to find much about it's origin or who created it and am curious as to why a full stop was chosen to represent this command.

12
  • 2
    Did you try to ask Stephen Bourne?
    – schily
    Commented Jul 28, 2018 at 21:24
  • 1
    @schily: He wasn't available to chat
    – jesse_b
    Commented Jul 28, 2018 at 21:28
  • 8
    Because it would be silly to call "%" the "dot command". Commented Jul 28, 2018 at 21:52
  • 1
    @slm: Correct, why was . used to represent the dot(source) command? Is it related to . being the current directory?
    – jesse_b
    Commented Jul 28, 2018 at 21:56
  • 1
    @Rob: No it's not.
    – jesse_b
    Commented Jul 29, 2018 at 1:57

2 Answers 2

7

The earliest mentioning of the dot command that I can find is in the manual for Stephen Bourne's sh shell in Unix Release 7 (it may be older, but not evidently present as one of the built-in commands in sh in Release 6).

. file  Read and execute commands from file and return.  The search path
        $PATH is used to find the directory containing file.

The dot, in quite general terms, seems to have been associated with "here" or "current". The . directory is the current directory, and the . address in the adb debugger from the same release of Unix had a . address which was the current address. Likewise, entering a . followed by newline in the ed editor will re-display the current line of the editing buffer (. addresses the current line). The dot also means the current node in certain structured query languages for XML, JSON, YAML, etc. (although these are later inventions).

It is therefore, I think, not too far fetched to speculate that the . command in the shell also means "here" or "current". In particular, "run this script in the current environment."

The dot is also quite quick and easy to type, and having a short command for doing a common task (whether it be in ed, adb or in the shell) may have been another reason why another longer name was not used.


Note that I don't have a functioning version of sh from Release 7 to test things in, and that I can't find the actual implementation of . in Bourne's shell from that release in the above-mentioned Git repository, so I can't say for sure that it actually did exactly what it does today. But it's likely that it did.

2
  • +1. Thanks for this long answer. By the way, is there any difference between dot and source when used to run commands from a file: . scriptfile versus source scriptfile in bash? In other words, are they two names of the same built-in command?
    – sudodus
    Commented Jan 15, 2019 at 14:57
  • @sudodus They are equivalent. The source command has a different history though, as it's inherited from csh.
    – Kusalananda
    Commented Jan 15, 2019 at 15:17
2

May it be because dot is the name of the symbol ..

1 : a small spot

1
  • +1. Yes of course, this is the short answer ;-)
    – sudodus
    Commented Jan 15, 2019 at 14:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .