Skip to content

fix(cli): quote the env lines init writes, and point the next run at a custom tests dir - #1424

Merged
Chemaclass merged 3 commits into
TypedDevs:mainfrom
bfs2021:fix/init-quote-space
Oct 28, 2026
Merged

Chemaclass merged 3 commits into
TypedDevs:mainfrom
bfs2021:fix/init-quote-space

Conversation

@bfs2021

@bfs2021 bfs2021 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

bashunit init <dir> writes BASHUNIT_BOOTSTRAP=<dir>/bootstrap.sh to .env without quotes, and .env is sourced as shell. After bashunit init "my tests", the next bare bashunit dies with .env: line 1: tests/bootstrap.sh: No such file or directory (Fixes #1411).

Root cause

The value is written unquoted at src/cli/init.sh, so a directory with a space makes the shell read the line as an assignment followed by a command. A custom directory was also invisible to discovery: bare bashunit searches BASHUNIT_DEFAULT_PATH ("tests"), which init "my tests" never set.

Fix

The env lines are written double-quoted, escaping the characters that are special inside double quotes (\, ", $, backtick), so .env reads them as one assignment. The idempotent write (exact-match skip, comment an older value out, append — #1175) moves into a small helper both lines share. A custom directory additionally writes BASHUNIT_DEFAULT_PATH="<dir>", so the example test runs on the next bare invocation.

Testing

New acceptance test test_bashunit_init_with_a_space_in_the_directory_runs_afterwards (init into a spaced directory, then run bashunit there: no "No such file or directory", "1 passed") fails on the current code and passes with the fix; test_bashunit_init_updates_env now expects the quoted equivalent. The whole tests/acceptance/bashunit_init_test.sh: 18 passed, 1 pre-existing conditional skip. This machine is Windows (the package declares unix-only, make/shfmt unavailable), so the full-suite gates run in CI; note the branch was pushed through the GitHub REST API because git-over-443 was unreachable from here — the commit content is identical to a local push.

bfs2021 and others added 3 commits October 29, 2026 05:05
…a custom tests dir

.env is sourced as shell, so an unquoted BASHUNIT_BOOTSTRAP turned a
directory with a space into a command and broke every next run with an
error naming a path the user never typed. The value is written
double-quoted with the special characters escaped.

A custom directory also needs BASHUNIT_DEFAULT_PATH, or the next bare
bashunit finds no tests; the shared idempotent write moves into a
helper so both lines get the same re-init treatment.
The merge with main dropped the Unreleased Changed entries and reordered the
sections. The init reference now shows the quoted BASHUNIT_BOOTSTRAP line and
the BASHUNIT_DEFAULT_PATH line written for a custom directory.
@Chemaclass

Copy link
Copy Markdown
Member

[Claude] Reviewed and pushed 76c675d. The code change holds: names with a space, ", $, a backtick or \ load back from .env unchanged on Bash 3.2 and 5, and a second init adds no lines. Fixed two things: the merge with main had dropped the Unreleased ### Changed entries (#1392 and the docs wording) and reordered the sections, and docs/command-line.md still showed the unquoted .env line and did not mention BASHUNIT_DEFAULT_PATH.

@Chemaclass
Chemaclass merged commit ca6ce59 into TypedDevs:main Oct 28, 2026
37 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.

init writes an unquoted bootstrap path to .env, so a tests directory with a space breaks the next run

2 participants