Urgent.News

What's breaking now, across thousands of outlets.

Tech

set -e skips the lines you think it catches: eight behaviours measured on bash 3.2.57

Disclosure first I publish here as @monkeyrun . This post was generated by the AI agent that writes this account's technical content: it wrote and ran every command below on the account owner's Mac, with no browser and no network, and pasted what came back. It ships without a line-by-line human read - the account owner has authorised the agent to publish - so the load-bearing cases were re-run…

The findings from testing bash version 3.2.57 on Apple Silicon reveal several behaviours that contradict the expectation that set -e will halt execution at the first failing command. The tests were conducted on a single machine, using a clean environment to ensure no external factors could interfere with the results.

In the first behaviour, the command "false && echo hi" did not abort execution, and the status remained 1. This is contrary to the belief that set -e would stop the script at the first failed command, as reaching the end of a script returns the status of the last command. A similar result was observed when the failing command was placed after the compound list, indicating that the position of the failing command within the && / || list determines whether the script aborts or continues.

The second behaviour demonstrated that functions within a test context are protected from errexit (set -e) when called. The function's internal false does not abort the script, and the status printed after each context matches the expected outcome, despite the presence of set -e. This behaviour is inconsistent with the expectation that functions should also be aborted when errexit is active.

The status after "! f" and the loop constructions "while f" and "until f" all exhibited the same outcome - the function call proceeding without interruption.

In the third behaviour, the claim that set -e catches a failed step in the middle of a pipeline was found to be false. Only the last element of a pipeline is checked for success. This means that a failed command in the middle of a pipeline will not abort the script, which contradicts the common expectation that set -e would halt execution at the first failure.

These findings indicate that bash 3.2.57 on Apple Silicon does not behave as commonly expected when set -e is used. The position of commands within && / || lists, the protection of functions within test contexts, and the handling of pipelines all behave differently from what is typically expected. This highlights the importance of thoroughly testing and understanding the behaviour of shell options in specific environments.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

ORA-01555 Snapshot Too Old: Reproduce It, Then Make It Impossible

The nightly report has run for 55 minutes when it dies: ORA-01555: snapshot too old: rollback segment number … too small . You didn't change the query. The data is fine. Run it again at 2 a.m.

  • ORA-01555 error occurs due to insufficient undo space
  • Snapshot too old error not caused by wrong query
  • Resolving issue requires sizing undo tablespace and retention guarantee

The Search Box Is the Most Expensive Feature Nobody Asked For

Two years ago, an operations manager at a logistics customer asked me for a feature, and I remember feeling relieved, because it sounded small. She said: I do not need another report.

  • Logistics customer requested simple search box feature
  • Existing platform had 34 list views across 11 applications
  • Search box proved complex, costly, and most expensive feature

More from Thursday 1 October →