Fix mktemp templates on macOS#25
Merged
Merged
Conversation
merefield
commented
Apr 3, 2026
Owner
- fixes the tmp file building on zsh
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes temporary file template usage so mktemp works correctly on macOS/BSD (and avoids failures when the XXXXXX placeholder is not at the end of the template), with corresponding updates to the smoke tests.
Changes:
- Updated
mktemptemplate strings to placeXXXXXXat the end (e.g.,*.log.XXXXXX,*.json.XXXXXX). - Added an in-code note documenting the BSD
mktemptemplate constraint. - Updated
test/smoke.batsto match the new temp file naming pattern.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| clai.sh | Updates temp file templates for tool/payload/response/curl-error and command stdout/stderr to be BSD mktemp-compatible; documents the constraint. |
| test/smoke.bats | Adjusts the run_cmd smoke test helper to use the updated mktemp template convention. |
Comments suppressed due to low confidence (1)
clai.sh:116
create_secure_tempnow documents that BSDmktemprequires theXXXXXXplaceholder at the end, but it still accepts any template and will fail with a relatively opaquemktemperror if a caller passes an invalid template (e.g.,foo.XXXXXX.log). Consider validating that the template ends withXXXXXX(or at least contains a trailing run of Xs) and emitting a clear error message before invokingmktempto prevent future regressions.
create_secure_temp() {
# BSD mktemp requires the XXXXXX placeholder at the end of the template.
local template="${1:-${SESSION_TMPDIR}/clai.XXXXXX}"
local tmpfile
tmpfile=$(mktemp "$template") || return 1
chmod 600 "$tmpfile" 2>/dev/null || true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.