(Thanks to @red_menace, @fdo, and @nohillside so far. I've upvoted @red_menace's. It's "correct", but I found it difficult to grasp. I didn't really get it, until I read @fdo's link (first comment) as well. So, I feel this needs a more comprehensive answer for anyone else looking...)
First, it has nothing to do with AppleScript. Instead, in my example in the question:
- the
osascript
part can be "any program[/commmand] that can read from standard input (cat
is by far the most common)."**
- the
-- some AppleScript Code
part is any number of lines that you could otherwise type into standard input or feed into the "program" from a file, etc.
- In the
<<EOS
part, The EOS
isn't special. It's purely the <<
that's key. The EOS
part can be pretty much any single word (ie. string, no spaces or most special characters, etc.)
The result: it will perform the command with the encapsulated text as its input.
In my example, osascript
is simply a shell command that receives AppleScript code as its input and runs that code as if the same code was run in Script Editor, etc.
**Quoted from @fdo's link. See that for more details
<<
inman bash
might help :-)EOS
and<<EOS
, with no luck because (I now realize) there's nothing special about theEOS
. It can be (almost) anything. It's purely the<<
that's key. That wooledge link is very clear. Especially the "Here, somecommand can be any program that reads from standard input (cat is by far the most common), and WORD can be any delimiter word you like. (EOF is a common choice.)". Thanks!