I’m Blake. I write about probability, stochastic processes, Python tooling, and the practical side of building things with code. More about me →

  • Understanding `set -euxo pipefail` in Bash Scripts

    Many bash scripts you’ll see in the wild often have some variation of set -euxo pipefail at the top of the file. These settings make your scripts fail loudly and early when something goes wrong

    I’m constantly looking this up whenever I come across it, so here are my quick notes for us to refer back to if/when we need a quick refresher.

    set -e (Exit on Error)

    The set -e option instructs Bash to immediately exit if any command (excluding certain contexts like while or if conditions, or the right-hand side of a pipeline) returns a non-zero exit status.

    Bash will continue even if a command fails. set -e brings Bash closer to the behavior of other languages, ensuring that a failing command stops the script right away.

    set -u (Unset Variables are Errors)

    When set -u is active, referencing any variable that hasn’t been previously defined (with exceptions for $* and $@) will cause the script to immediately exit with an error.

    By default, Bash silently uses an empty string for the unset/mistyped variables. This flag prevents common typos from creating new, empty variables without you realizing it.

    set -x (Print Commands)

    This option enables trace mode, printing each command’s expanded form to standard error immediately before it is executed. set -x helps you visualize the flow of your script by showing exactly which commands are being run and with what arguments.

    set -o pipefail (Fail on Pipeline Errors)

    By default, the exit status of a pipeline (command1 | command2) is the exit status of the last command, even if an earlier command in the pipeline failed. set -o pipefail changes this, ensuring that the entire pipeline’s exit status is that of the first non-zero exit status encountered.

    This flag prevents errors in the middle of a pipeline from being silently ignored. For instance, if grep fails to find a file but pipes its (empty) output to sort, sort will succeed, and the pipeline would report success. With pipefail, the pipeline would correctly report grep’s failure.

  • Dare to give a Sh*t

    Recently I came across a video from author John Green about hope. The central message (paraphrased) I took away from his words was:

    Chose hope. Nihilism is the easy way out. When you believe nothing truly matters, there’s no reason or motivation to fight for a better world. Choosing hope is the harder path, but it makes change possible — and inevitable.

    This week, I lost a friend to Leukemia. Fi Milne hired me at the end of 2024 after a year of layoffs (a story for another time). We worked together for about 8 months before a sudden and disheartening diagnosis of Leukemia. The news of her passing this week shook me to my core, and I was frozen without words or actions. The world stood still, before it started to sink in over the next few days.

    Over time as the sorrow progressed, I reflected more on who Fi was and what she meant to me and my team. Hearing how she impacted each member of my team was incredible — I was far from the only lucky one. One day on a walk, I was struck with a thought, and it was suddenly clear how her memory will be honoured:

    Be like Fi

    The timing of Greens message was coincidental, but it was the push I needed to dig deeper and dare to reach out to my friends here. Fi was an incredibly good listener — a skill I think we will all forever be improving. Initiating the conversation with them helped us all tremendously, whether it was reflecting on Fi or talking about unrelated topics and having a laugh.

    I’m sorry things ended too soon Fi. Your memory will live on through the tremendous impact you had on everyone on your journey. Even in a relatively short time, you inspired me and helped me learn how to care more for my team members and provide support to those with the will to fight for a better world.

    If you have the resources to do so, consider donating to WiMLDS to help continue one of her missions to support and empower women in machine learning and data science

  • Catching burnout while you're still capable

    This is something I’ve written on a sticky note on my desk recovering from burnout for the N’th time:

    - Harder to wake / morning drag
    - Sleep doesn't restore me
    - Irritable at minor friction
    - Routnes slipping
    - Avoiding basic maintainance
    - Functioning on autopilot
    
    If >3, intervene today

    I don’t know why this always surprises me, but to avoid (or at least lessen) burnout episode N+1. I felt I needed to write a reminder to my future self so that I can be reminded of the early warning signs.

    Maybe it wont stay next to my monitor, but I will set a reminder to check this every Saturday morning

    It’s important to internalise that burnout is not a weakness, it’s ignored limits and a delayed response. Burnout is a fickle beast that only makes itself known well after damage has been done. In cases like this, preventative measures are always better than treatment in the long run.

  • Revising Self-Reliance in an Age of Saturation

    When I moved out of home, I came across this enjoyable and informative article from Brett Mckay on establishing a self-reliant mentality

    One of the best answers I have found to this question actually comes from a great, albeit endearingly cheesy, 1950s educational film called “Developing Self-Reliance.”

    1. Assume responsibility
    2. Be informed
    3. Know where you’re going
    4. Make your own decisions

    However, 7 years later the landscape has changed quite dramatically in terms of civil discourse. After feeling a bit burnt out, I decided to revisit these tenets and I revised them:

    1. Be accountable
    2. Seek understanding, avoid saturation
    3. Act with direction
    4. Decide with evidence and compassion

    Today the threat isn’t ignorance, it’s saturation. “Be informed” becomes seek understanding, because raw intake without synthesis breeds anxiety, not agency.

    Accountablity narrows to what’s actually controllable, because pretending you can carry everything is burnout masquerading as virtue.

    Direction replaces rigid goals, acknowledging that clarity now comes from iteration, not certainty.

    Decision-making can no longer be just independence for its own sake — it has to be evidence-based, compassionate, and forward-looking, or it collapses into reflexive tribalism.