Documentation

36.36 Robust scripting in PowerShell, shells, and pipelines

Robust scripting in PowerShell, shells, and pipelines
Structural reference diagram

This chapter is a lookup reference for nlmx 4.16.1. Option tables are generated from the installed release executable. Read an option in the context of the command page: nlmx uses a global parser, but an accepted option can be irrelevant to a command unless its help text names that command or the command's method chapter defines the behavior.

The safe sequence is: identify the installed version, open that command's help, freeze input/settings/output paths, run into a new or empty output directory, inspect both the process status and the command-native verdict, and retain the log/resolved settings/checksums. A command line is reproducible only when its referenced files and software version are also frozen.

PowerShell pattern

$exe = (Get-Command nlmx).Source
& $exe qc-data data/analysis.csv -c study.qcd -o results/qc-data --no-color
$code = $LASTEXITCODE
if ($code -ne 0) { throw "qc-data process failed with exit $code" }
if (-not (Test-Path -LiteralPath results/qc-data/checksums.sha256)) { throw "missing checksums" }

POSIX-shell pattern

set -euo pipefail
nlmx validate -c study.covar -o results/validate --no-color
test -f results/validate/validation_verdict.json

These are process guards, not complete acceptance tests. Add command-native assertions: expected verdict field, model convergence/covariance status, required table rows, sample/subject counts, exclusion limits, expected version, and checksum verification. Quote paths, avoid shell-expanded wildcards unless intended, and never build a command by concatenating untrusted data.

Freeze each run into a new directory. Capture nlmx version --no-color, the command and working directory, input hashes, settings, relevant environment, start/end times, process exit, semantic verdict, and reviewer disposition. Parallel jobs need separate outputs and logs. A retry should create a new attempt record or preserve built-in retry lineage; it must not erase the failed attempt that explains why the workflow changed.

Novice review checklist

  • Can you identify the exact installed nlmx version and canonical command?
  • Are positional inputs, named options, settings, and output paths unambiguous?
  • Did you distinguish parser acceptance from command-specific meaning?
  • Will the run preserve enough native evidence to determine semantic success?
  • Is a qualified human decision required after the software completes?

See the previous page, next page, and complete command index.