Repository navigation
fix(motd): keep colour when TERM is only bash unexported fallback - #107
Merged
Merged
Conversation
added 2 commits
December 1, 2026 07:02
Non-interactive login shells (PAM/run-parts) run the payload with no TERM. Bash then synthesises an unexported TERM=dumb, which the previous check read as a colourless request, so SSH PTY logins lost the palette and the Chinese last-login line rendered without SGR. Only an explicitly supplied TERM=dumb disables colour now: an unexported placeholder reports no export attribute. NO_COLOR is unchanged. Refresh both payload sha pins and add a missing-TERM regression assertion alongside the existing explicit dumb and NO_COLOR cases.
PAM runs the payload without any hint of the client's theme, so the fixed palette was chosen blind. In the reported light-theme login the white last-login time sat near 1.9:1 against the surrounding background and the fixed label colour near 1:1, which is why the panel looked washed out or disappeared there. Body text, labels, the prompt line, the hero divider, the progress track, uptime units and the architecture note now use the default foreground (SGR 39) so the terminal theme decides light or dark. Accents use only basic ANSI indices, which each client maps onto its own palette: the host name uses blue, the load average cyan, system version and last-login source magenta, idle CPU model and kernel yellow, uptime numbers and healthy usage green, and the warning states yellow and red. Colour meaning, weight and layout are unchanged: the same fields keep their distinct accents, and plain text output is byte-identical at 80, 60, 40 and 32 columns. The unexported-TERM fallback fix, explicit TERM=dumb and NO_COLOR remain plain text. Payload pins refreshed in both entries; assertions now require absence of fixed truecolour, 256-colour and bright indices, and the last-login time must carry no fixed RGB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Non-interactive login shells (PAM /
run-parts) start the MOTD payload with noTERM. Bash then synthesises an unexportedTERM=dumb, which the old guard[[ "${TERM:-}" == dumb ]]read as an explicit colourless request. On real SSH PTY logins to usnc this dropped all SGR, so the welcome panel, the Chinese time and the last-login source rendered plain.The guard now disables colour only when
TERM=dumbwas actually exported by the caller:( "${TERM:-}" == dumb && "${TERM@a}" == *x* ). An unexported Bash placeholder reports no export attribute, so the palette is restored.NO_COLORhandling is unchanged.Scope
tools/setup-motd.shandmodules/system-customize.sh: the identical MOTD payload, same one-line guard change in both.MOTD_PAYLOAD_SHA256pins refreshed to the new payload hash994857572414bb1f63e0104b980e461964d9884ba9329dd61f4fd3580b493b2c.tests/test-motd.sh: payload hash pin refreshed; existing explicitTERM=dumbandNO_COLORassertions kept; one new regression assertion for the missing-TERMcase (must stay coloured and text-identical).No site-specific config, no hkaz hook or date-colour work, no unrelated refactors.
Validation
Local, seconds-scale only (full MOTD suite left to CI):
bash -non all three touched scripts: pass.git diff --check: clean.994857572414bb1f63e0104b980e461964d9884ba9329dd61f4fd3580b493b2c, matching both pins and the test pin.env -u NO_COLOR/NO_COLOR=1as noted):TERM(Bash fallback, unexported): ANSI present, text identical to the coloured runTERM=dumb: no ANSINO_COLOR=1withTERM=xterm-256color: no ANSITERM=xterm-256color: ANSI presentenv -i PATH=... bash -c '...':TERM=dumb, attribute[](unexported), confirming the fallback signature.Configured-vs-behaviour caveat: the above is a local payload check, not a re-run of the full suite and not a real SSH login.
Risks
Low. The change only narrows when colour is suppressed. Terminals that explicitly receive
TERM=dumbstill get plain output, andNO_COLORstill wins. Servers where the payload is invoked with a genuinely exportedTERM=dumbkeep the previous plain behaviour.Rollback
Revert this squash commit; the payload hash pins and the regression assertion revert with it.
Closes the colour regression only. hkaz's dated administrator hook keeps its own date-colour issue and is out of scope here.