Every script a build runs with bash, devvm's own and the user's layers,
now gets the prelude as one line, eval $'…', in place of its #! line, so
bash's errors and $LINENO give the script's own line numbers. A script
without a #! line is one line further down.
- shell.QuoteLine: ANSI-C quoting for bash, on one line of printable
ASCII; every other byte as \xHH, so a multibyte locale's lead byte
(Shift-JIS, GBK, GB18030, Big5) can't swallow the backslash escaping a
quote, and a NUL panics as a caller's bug. image's layer rule allows
internal/shell, a leaf.
- image.WithPrelude, the one place the prelude and a script are joined
(OwnScript calls it), used by base.sh, apt.sh, the built-in layers and
features, the user's layers, shared-tools/build.sh and oci/build.sh.
Every devvm script has a #! line. A leading UTF-8 BOM goes before the
#! check.
- A build's exports for a company proxy (lima's proxyExports) and the
user's CAs (trust's exports) end in "; ", not a newline, so they share
the first line and move no line either; backend.Trust.Env says so.
- The stub logs a bash -s script's second line, which is the script's
own second line with or without the prelude.
- Keys: every build script's bytes change, so base, every image and
every shared tool image are built again once; the CHANGELOG's After
you upgrade says so with git-lfs, and what VMs say until devvm update,
and Breaking has its own heading.
- Tests: TestQuoteLine (every byte but NUL, a break-out word, in
/bin/bash 3.2 and PATH's bash, in C and each of ja_JP.SJIS, zh_CN.GBK,
zh_CN.GB18030 and zh_TW.Big5 that locale -a has), TestQuoteLineNUL,
TestWithPrelude's shebang and BOM cases, TestWithPreludeRuns (the real
prelude's line gives the prelude back; a layer under set -euo pipefail
gets the names, keeps its function and its line numbers, with and
without exports before it).
- e2e nix: the layer copy no longer adds the prelude itself.
- Docs: images.md's prelude section, Customizing's layer bullet,
structure.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
internal/shell, a stdlib leaf: Quote, QuoteJoin and EnvName. They
replace the 4 shell quoters (lima's shq and shqJoin, docker's shq, vm's
and devcontainer's shellQuote) and the 4 variable-name regexes (docker's
envKey, vmssh's envName, vm's envVarName, devcontainer's envName).
lima's quoting tests move there as TestQuote and FuzzQuote.
internal/vmname, a stdlib leaf below project: Prefix, HashLen, IsVM and
SlugOf. project's vmName regex, IsVM and Prefix go (callers use vmname),
lima's projectVM, docker's hostname parsing and cli's export-name regex
use it. TestImageKey (lima) pinned imageKey before the change;
TestParseExportName covers the export names.
Value patterns exported once: from.IsDigest (lima's idPattern),
image.IsKey (build's keyLike and the keyPattern copies in lima, docker
and smolvm), image.ToolVersion (tools' versionLike) and image.ToolName,
with TestIsDigest and TestValuePatterns. state's featureName stays:
internal/state may not import internal/image.
netpolicy.PolicyFiles names a user layer's policy file only for a part
image.LayerName takes, so an image-name part such as ../x never names a
file outside the user's layers; TestPolicyFiles's ../x cases failed
without the check.
The structure test's owners check gets literals: a non-test string
literal holding '\'' outside internal/shell, or [0-9a-f]{14} outside
internal/vmname, fails, naming the owner. TestRulesFail has cases that
break and keep both. shell and vmname join the leaves' layer, and
devcontainer may import shell. Coverage baselines: shell and vmname
added at 100.0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>