Get the latest tech news

Colodebug: A simple way to improve bash script debugging (2021)


In this article, I will show you an easy-to-use, simple, and non-disruptive way to extend a GNU bash script by a few lines that can help make sense of its execution flow at runtime a fair bit easier. Using this method will also allow you to effortlessly add a “verbose” execution mode to scripts you create or extend.

In this article, I will show you an easy-to-use, simple, and non-disruptive way to extend a GNU bash script by a few lines that can help make sense of its execution flow at runtime a fair bit easier. Usually, when something in your unfortunately-by-now-much-too-elaborate bash script goes wrong, there’s a few tricks to ease the burden of debugging it: Sprinkling a few echo(or, better yet, printf) calls all over, making it sleep, read or exit at neuralgic points, or enabling xtrace mode (via set -x) to get glimpses at what the interpreter is doing piling up on stderr. We modify our homebrew implementation of: to evaluate its first argument (if any - if there’s none, we substitute a dash for its absent value due to reasons), and, in case that happens to not be a sequence of bytes starting with two ASCII colon characters, exit with success.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of simple way

simple way

Photo of Colodebug

Colodebug

Related news:

News photo

Show HN: Lit.money – Ethically designed to be a private, simple way to see money

News photo

New battery-free electricity source: Tiny plastic beads | Harnessing a principle known as triboelectrification, researchers have worked out the optimal way to generate an electrical charge in a relatively simple way.

News photo

A simple way of visualizing Git repository