Take care editing bash scripts
Recommended read: Take care editing bash scripts https://thomask.sdf.org/blog/2019/11/09/take-care-editing-bash-scripts.html
Take care editing bash scripts
Recommended read: Take care editing bash scripts https://thomask.sdf.org/blog/2019/11/09/take-care-editing-bash-scripts.html
Anybody can write good bash (with a little effort)
I used to write a lot of shell scripts before realising that what I was trying to do was treat shell scripting as a "full" scripting language (I won't define here what I mean by "full").
Its not - reach for a higher level scripting language like Ruby or Python when things are getting more complicated, and allow shell scripts to glue things together, or be for quick tasks maybe a few lines long.
When you do write them, this advice is great but it's definitely worth gaining understanding of when you should and shouldn't use them.
Recommended read: Anybody can write good bash (with a little effort) https://blog.yossarian.net/2020/01/23/Anybody-can-write-good-bash-with-a-little-effort
Parsing a Unix Epoch With Bash/Ruby on the Command-Line (1 mins read).
How to convert a Unix Epoch to a human-readable date format.
Using Bash to automate Rubocop fixes
Recommended read: Using Bash to automate Rubocop fixes https://krmannix.com/2019/12/12/using-bash-to-automate-rubocop-fixes/
Recommended read: Beware of shell globs https://soptik.tech/articles/beware-of-shell-globs.html
Things You Didn't Know About GNU Readline
Recommended read: Things You Didn't Know About GNU Readline https://twobithistory.org/2019/08/22/readline.html
Recommended read: Stupid UNIX Tricks https://sneak.berlin/20191011/stupid-unix-tricks/
Use the Unofficial Bash Strict Mode (Unless You Looove Debugging)
This is a great article about how to be safer when writing shell scripts. I am a huge proponent of not using them where possible, and instead moving them to another scripting language (Ruby, Python, Node) which you can test, and use a shared standard library.
Recommended read: Use the Unofficial Bash Strict Mode (Unless You Looove Debugging) http://redsymbol.net/articles/unofficial-bash-strict-mode/
Adding Newlines to all Files in Git (3 mins read).
Adding newlines at the end of all Git-tracked files.
Tricking the tricksters with a next level fork bomb - Vidar Holen
A sneaky and interesting way to trick someone into running a fork bomb, even if they know it may be one!
Recommended read: Tricking the tricksters with a next level fork bomb - Vidar Holen https://www.vidarholen.net/contents/blog/?p=766
https://www.vidarholen.net/contents/blog/?p=746
In every programming language, there is a linting tool that can help pick up on some common style issues. ShellCheck isn't one of those - it's so much more!
I've been using it for many years now, and since it came into my life it's honestly changed the way I use shell scripts. There have been so many pitfalls that I've avoided falling into since learning about them (and adding ShellCheck to my Vim linting setup.
This is a great read from Vidar, the ShellCheck author, about a case where it could've caught issues that caused the deletion of a production database!
Recommended read: https://www.vidarholen.net/contents/blog/?p=746 https://www.vidarholen.net/contents/blog/?p=746
Automating Promotion of Jekyll Posts from Draft to Post (2 mins read).
The handy script I've created to automate publishing a draft in Jekyll, with handy Zsh + Bash autocomplete.
My editorial workflow for blog posts (8 mins read).
Taking you through the journey I go on when writing blog posts, from ideation to publishing the post.
Viewing Git history of a file in git log
while ignoring file renames (5 mins read).
How to track changes to files in Git without pesky file renames getting in the way, using git log --follow
.
SSLError
When Running Berkshelf Behind a Proxy (2 mins read).
Getting around the pesky OpenSSL::SSL::SSLError SSLv2/v3 read server hello A
error when running Berkshelf behind a proxy.
Viewing your diff while writing your commits with git commit --verbose (3 mins read).
Making it easier to write commit messages by having the diff in your editor.
Extracting SSL/TLS Certificate Chains Using OpenSSL (1 mins read).
A quick one-liner to get you the full certificate chain in .pem
format.