From bec87f987ca916de25c589cb5c90e2f57565204d Mon Sep 17 00:00:00 2001 From: Dai Ha Date: Sat, 12 Sep 2026 12:58:37 +0700 Subject: [PATCH] scripts: name the mechanism in detect_supervisor's constraint 2, not a line number MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Constraint 2 read "This script runs under `set -euo pipefail` (line 50), so an unset variable is a loud failure." Two problems, both small and both the same family as fleetd #494 — a comment that states the wrong reason. The line number was stale: the `set` line is at 54, not 50. It was the only line-number citation in the file, and a citation like that goes stale on the next insert above it, silently, with nothing to catch it. The mechanism was also misattributed. What makes an unset variable a loud failure is `set -u`. Naming the whole `-euo pipefail` string invites the reader to credit pipefail for it, which is the mistake fleet01 flagged on a different cell this week: pipefail is insurance against a future pipeline stage, not what catches the current shape. Now names `set -u` and says where it is without a number, and records why the number is gone so nobody adds one back. Comment only. bash -n exit 0 under /bin/bash 3.2.57 and env bash 5.3.9; scripts/test-redeploy-fleetd.sh exit 0 with 0 lines matching ^FAIL:. --- scripts/redeploy-fleetd.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/redeploy-fleetd.sh b/scripts/redeploy-fleetd.sh index 5d46f28..0095b31 100755 --- a/scripts/redeploy-fleetd.sh +++ b/scripts/redeploy-fleetd.sh @@ -306,10 +306,12 @@ systemd_loaded() { # never assigned to a global: a global set inside a `$( )` subshell dies with that subshell. # This function packs BOTH values (kind and detail) onto that one stdout line, joined by # $SUPERVISOR_DETAIL_SEP, and the caller unpacks them on its own side of the subshell boundary. -# 2. This script runs under `set -euo pipefail` (line 50), so an unset variable is a loud -# failure. Do not add a `${VAR:-default}` anywhere downstream to paper over a value that -# should always be there — that hides a lost value instead of surfacing it (fleetd #497's -# defect class). +# 2. This script runs under `set -u` (part of the `set -euo pipefail` at the top of the file), so +# an unset variable is a loud failure. Do not add a `${VAR:-default}` anywhere downstream to +# paper over a value that should always be there — that hides a lost value instead of +# surfacing it (fleetd #497's defect class). The mechanism is named rather than cited by line +# number on purpose: a line number in a comment goes stale on the next insert above it, and +# this one already had — it said line 50 while the `set` line was at 54. # 3. Every `case` on this function's return value needs an explicit final `*)` arm, chosen by # whether that caller ACTS on the value (`die` — an unrecognised value must never be silently # driven) or only DISPLAYS it (`echo`/`warn` and continue — a diagnostic must not go silent on