Anyone have any favorite/creative delimiters for HEREDOCs or other string formats that accept user-created delimiters?
I tend to default to EOF, but that character sequence isn't *that* unlikely to appear in the text.
> Anyone have any favorite/creative delimiters for HEREDOCs or other string formats that accept user-created delimiters?
I'm almost embarrassed to admit that it took seeing my own question for me to realize it, but § is a great delimiter – unlikely to occur in most strings, semantically meaningful, and easy-ish to type (via a compose key on Linux or opt-6 on mac). Plus, it's short enough to repeat if it's present in the text
I think I'm going to switch to § (maybe with a content tag: §html)
@codesections EOF alone on a line isn't particularly common. Either way, if you do happen to need it in a here-doc, you can easily choose something else on those occasions.
> That's not ascii-safe, though.
For most of the code I write, the ascii-safe ship has not only sailed but is well out to sea 😁
I stopped using HEREDOCS in favor of the Python Click library and the sh library.
Better for testing and CICD
@codesections I usually include the content type, similar to markdown. So your suggestion of section symbol + content type seems ideal.
As an added bonus, it's in Latin1
@codesections It took me *far* too long to realise that § was a better delimiter than ⭲; in fact, I only realised three days ago.
@wizzwizz4 That didn't render for me. Is it https://www.fileformat.info/info/unicode/char/2b72/index.htm ?
@codesections I think so.
The character trashes my text editor (Geany), too; if it's the first character on a line, all the leading spaces become 1-pixel wide, and it breaks the monospace. And I was going to use it as the “attribute access” character in my programming language.
@brandon @codesections Because I was using most of the punctuation as punctuation. Dot was full stop, comma was comma, semicolon was semicolon. Arrows were used for function prototypes, colons were used for type designation (and ratios)…
I wanted an easy-to-type one, but I thought I'd run out. Turns out the section sign was unused, though.
head -c 35 /dev/urandom | base32
ASCII-safe, less likely to occur in some arbitrary text than a disc error causing an actually unique text to pop at random, and I see no reason for the delimiter to be very short (it's not like I type it manually anyway). When I need some artificial delimiter which needs to be short, I like broken bar “¦” (0xA6) since I don't think I've ever seen a “natural” use for that. (Not ASCII safe, though, but I very rarely need that these days.)
Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.