standardebooks / web

The source code for the Standard Ebooks website.

Home Page:https://standardebooks.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sed --in-place isn’t posix compatible

robinwhittleton opened this issue · comments

<p>Notice that in our source file, each chapter is marked with an <code class="html"><span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span></code> element. We can use that to our advantage and save ourselves the trouble of adding the <code class="html"><span class="c">&lt;!--se:split--&gt;</span></code> markup by hand:</p><code class="terminal"><span><b>sed</b> --in-place <i>"s|&lt;h2|&lt;!--se:split--&gt;&lt;h2|g"</i> <u>src/epub/text/body.xhtml</u></span></code>

Unfortunately switching from perl to sed has broken macOS compatibility, as --in-place is a GNU thing. Short of requiring mac users to brew install gnu-sed there don’t seem many clean options (see https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux).

What was the rationale for switching in the first place?

For consistency, since sed --in-place was used elsewhere in the guide but perl wasn't. But it looks like most of those have been replaced with interactive-replace so if you want to replace all of the instances of sed with perl then go for it.