No but your script will be portable as long as you escape any leading blank. Why ? Because some
seds strip blank characters from text lines and the only way to avoid that is to escape the leading blank, as these manual pages dating back from the last century explain: 1, 2, 3
The same goes for
OSX just copied the code, it's not their extension) and if you check the archives and read the
man page from
BSD 2.11 it's pretty clear:
An argument denoted text consists of one or more lines, all but the
last of which end with
'\' to hide the newline. Backslashes in text
are treated like backslashes in the replacement string of an
command, and may be used to protect initial blanks and tabs against
the stripping that is done on every script line.
Now, where is this documented in the POSIX spec ? It only says
The argument text shall consist of one or more lines. Each embedded
<newline> in the text shall be preceded by a <backslash>. Other
<backslash> characters in text shall be removed, and the following
character shall be treated literally.
and if you scroll down under RATIONALE it says
The requirements for acceptance of <blank> and <space> characters in
command lines has been made more explicit than in early proposals to
describe clearly the historical practice and to remove confusion about
the phrase "protect initial blanks [sic] and tabs from the stripping
that is done on every script line" that appears in much of the
historical documentation of the sed utility description of text. (Not
all implementations are known to have stripped <blank> characters from
text lines, although they all have allowed leading <blank> characters
preceding the address on a command line.)
Since the part with "backslashes may be used to" was not included in that quote, the remaining phrase "protect initial blanks..." doesn't make any sense...1
Anyway, to sum up: some implementations did (and some still do) strip blanks from text lines. However, since the POSIX spec to which all implementations should comply says
Other <backslash> characters in text shall be removed, and the
following character shall be treated literally.
we can conclude that the portable way to indent the lines in the text-to-be-inserted is by escaping the leading blank on each of those lines.
1: I also don't understand why
BSD people have changed the entire paragraph in the
man page without altering the source code - you get the same behavior as before but the man section that documents this stuff is no longer there.