is
: <<EOF
text
text
EOF
a bash-ism?
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
is
: <<EOF
text
text
EOF
a bash-ism?
AFAICT, not really, looks line POSIX sh at a glance. Just don't forget to : <<'EOF' instead of : <<EOF.
But : is arguably simpler than cat, one fewer fork/exec call plus no open(2) on /dev/null.
I like it, thanks :)
I think this solves an issue, that's not an issue at all and makes it more complicated and harder to read. What do I mean by that?
It requires more text and exact correct syntax of multiple elements. It makes it harder to see where the start and end is, and one has to look for any lines that could potentially be a comment in a heredoc. The syntax highlighter does not show this in comment color. Bash still executes those lines to read the "comment", as it thinks its normal code. In example variables can still be expanded in heredocs. Other tools removing comments from script to count lines would be fooled too.
Compare this to a single hashtag symbol in the beginning of each comment. That's all. This is also good practice everyone understands. From practical point of view, why would anyone use heredocs for multi line comments over single line comments?
Yeah but... Don't. Multiline comments are a bit of an anti-pattern at the best of times. This is a war crime.
I use this only when developing, mostly while debugging. IIRC I've never commited code like this.
Close notepad.exe. Open a real editor. Select the text you want to comment out. Press Ctrl-/
No notepad.exe, nvi: 'a,s/^/# /.
Your website is dead.
Oops, renamed the www dir, should be back now.