Skip to content

fix(_common): export KEY=value in toolkit.env sets KEY, not exportKEY (#579) - #609

Merged
MendixMau merged 1 commit into
masterfrom
triage/579-export-key
Nov 3, 2026
Merged

MendixMau merged 1 commit into
masterfrom
triage/579-export-key

Conversation

@MendixMau

Copy link
Copy Markdown
Owner

Part of #579

Root cause

project-bin/_common.sh:165 (mxtk_load_env, on master):

key=$(printf '%s' "${line%%=*}" | tr -d '[:space:]'); val=${line#*=}

This removes all whitespace from everything left of =. So export MENDIX_APP=/x becomes the key exportMENDIX_APP. That key passes the name checks and is exported, and MENDIX_APP stays unset. The comment at l.169 says "export KEY=value ... work". Note: the file is project-bin/_common.sh. There is no bin/_common.sh.

A second defect sits in the same lines (l.170-171): the quote strip ran before the whitespace trim. So KEY = "value" kept its quotes, because the value started with a space.

Fix

Evidence

Reproduced in a scratch project, sourcing master's _common.sh with a toolkit.env of export MENDIX_APP=/x/y, export MXCLI_VERSION="0.29.0", PYTHON = "/usr/bin/py":

master: MENDIX_APP=[] MXCLI_VERSION=[] PYTHON=["/usr/bin/py"]
        env: exportMENDIX_APP=/x/y  exportMXCLI_VERSION=0.29.0
fix:    MENDIX_APP=[/x/y] MXCLI_VERSION=[0.29.0] PYTHON=[/usr/bin/py] JAVA_HOME=[/j k] exportX=[1]

Fixture

New case 4b in tests/wave2/test-common-windows.sh, the existing mxtk_load_env fixture.

Against master's file (git show origin/master:project-bin/_common.sh), exit 1:

== 4b: mxtk_load_env — export KEY=value, quoted, and spaced forms ==
  FAIL  export/quoted/spaced keys misread, want '/from/export|0.29.0|/q/py|1|' (-> /from/user/file||"/q/py"|1|/from/export)
10 passed, 1 failed

Here MENDIX_APP fell through to the user file, MXCLI_VERSION was empty, the quotes were kept, and exportMENDIX_APP was set.

Against this branch, exit 0:

== 4b: mxtk_load_env — export KEY=value, quoted, and spaced forms ==
  ok    export/quoted/spaced keys read (-> /from/export|0.29.0|/q/py|1|)
11 passed, 0 failed

Only this fixture was run. The full suites were not.

Regression notes

  • A KEY=value line parses exactly as before.
  • A quoted value with spaces inside the quotes now keeps those inner spaces. Before, they were trimmed away after the strip.
  • A line that previously exported a stray exportKEY variable now sets KEY. Precedence is unchanged: an environment variable that is already set still wins.
  • Field run: none on a real project's toolkit.env. The evidence is the scratch reproduction and the fixture above.

CHANGELOG line under ## Unreleased, same commit.

Review: pending independent review


Generated by Claude Code

…#579)

mxtk_load_env (project-bin/_common.sh:165) built the key with
tr -d '[:space:]' over everything left of '=', so 'export MENDIX_APP=/x'
exported 'exportMENDIX_APP' and MENDIX_APP stayed unset, though the comment
two lines below says the export form works. A leading 'export<ws>' is now
dropped first (pure bash, bash 3.2 safe, no new subprocess). Also: the
quote strip ran before the whitespace trim, so 'KEY = "v"' kept its quotes;
the trim now runs first.

Fixture tests/wave2/test-common-windows.sh case 4b: fails against master's
_common.sh (10 passed, 1 failed), passes with the fix (11 passed, 0 failed).

Part of #579

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018LeNWZV2sVH62vkgfYh5u5
@MendixMau
MendixMau merged commit 04d6d2c into master Nov 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants