(Let me know if this is the wrong SE for this)
Why is a Here Document (or Heredoc) called that? Wikipedia didn't have anything to say on that particular subject. I did find unix docs describing a "Here is document", is that the original form?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
Some teleprinters* had a sequence of a dozen or two characters that could be programmed (mechanically) into the unit and was sent when the host sent an
ENQ character or the operator pressed the
HERE IS key on the keyboard. A number of glass-tube terminals had the same feature.
A "here-is" document in shells and programming languages that support the same construct serves essentially the same purpose: it's a canned sequence of characters that doesn't change unless the program does.
*These are also the origin of the term
tty that appears in Unix.
Well, the document is right here. Here it is. It's a logical name for the thing, yeah?
When people speak of 'here documents' they are generally speaking of a unit of data that is embedded into code. That data will be displayed to a user or used to compose a request to a server or to write information to a log or to update a configuration file, or, or, or,or... It's a mistake to overload the name with meanings and connotations. It's a programming technique and it has a name.
It's called a here document because it is 'here', in the source file that needs it, rather than being elsewhere, as a separate file. I guess looking deeper into it would be rather like trying to analyse the term '4 wheel drive' in great depth.
It can be very convenient to have your data within your code.
Because it's all data from << HERE
all the way
wait for it