← ClaudeAtlas

padosoft-cross-platform-scriptinglisted

Use this skill when writing or reviewing a script that has to run in more than one place — a developer's Windows machine and a Linux CI runner, a Makefile, a validator, a hook, a release script — and whenever the user says it works locally but fails in CI (or the reverse), a command reported success while the step failed, a path is not found on one platform only, a dotfile is invisible, a file with an accented name is skipped, or a regex misses lines on one checkout. It covers exit-code propagation, path and case semantics, interpreter discovery and how not to parse another tool's human output. Do not use it to choose a scripting language, for container or deployment configuration, or for CI workflow design.
padosoft/skills · ★ 1 · Data & Documents · score 80
Install: claude install-skill padosoft/skills
# Cross-platform scripting The script runs on a Windows workstation and on a Linux runner. Everything below is a way those two disagree **silently** — the script does not crash, it reports success while having done something else. --- ## 1. Exit codes: capture each one, immediately ```powershell # ❌ only the last command's status is checked — the first failure is invisible tool-a ; tool-b ; if ($LASTEXITCODE -ne 0) { exit 1 } # ✅ tool-a ; $a = $LASTEXITCODE tool-b ; $b = $LASTEXITCODE if ($a -ne 0 -or $b -ne 0) { exit 1 } ``` Two traps, both from the same variable: - **It persists.** `$LASTEXITCODE` keeps the value of the last native command run anywhere in the script, **even when that failure was handled** and the script went on to succeed. A wrapper that propagates it at the end turns a handled error into a failed job. - **A non-terminating error is not a failure** in PowerShell: suppressing the *message* does not change the status, and conversely a cmdlet that "failed" may leave the previous native exit code untouched. In POSIX shell the equivalents are `set -o pipefail` (a failing command mid-pipe is otherwise invisible) and checking `${PIPESTATUS[@]}` when you need each stage. ## 2. Never parse another tool's human output An error renderer is a UI: it carries ANSI codes, wraps lines where the terminal ends, and inserts context between the message and the path. Stripping ANSI is not enough, because the line breaks are the renderer's too, and they move when