Skip to content

Fail if the output file cannot be written - #212

Open
gdevenyi wants to merge 1 commit into
matejak:masterfrom
gdevenyi:fix/report-unwritable-output
Open

gdevenyi wants to merge 1 commit into
matejak:masterfrom
gdevenyi:fix/report-unwritable-output

Conversation

@gdevenyi

Copy link
Copy Markdown

A failed redirection to the output file (for example a non-existent directory, or a file owned by another user) only produced a shell diagnostic - argbash still exited with status 0, so callers such as make carried on with a stale or missing output. argbash now dies with a clear message and exit status 1.

New regression test test-unwritable-output.

🤖 Generated with Claude Code

https://claude.ai/code/session_017DxhC3HmTM7TQUzkBZnyH2

Copilot AI lite review requested due to automatic review settings September 11, 2026 21:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical and moderate review comments remain.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates argbash to fail with status 1 when it cannot write the requested output file.

Changes:

  • Adds output-write failure handling.
  • Adds unwritable-output regression coverage.
  • Updates generated artifacts and ChangeLog.
File summaries
File Summary
tests/regressiontests/Makefile Registers the regression test.
tests/regressiontests/make/tests/tests-base.m4 Adds the test; moderate comment requests asserting status 1 (1 vote).
src/argbash.m4 Adds write-failure handling; critical comment requests propagating recursive generation failures (1 vote).
ChangeLog Documents the bug fix.
bin/argbash Updates the generated executable.
Review details

Suppressed comments (1)

tests/regressiontests/make/tests/tests-base.m4:349

  • This regression only uses reverse, which considers any non-zero status a pass. Since the PR contract is specifically exit status 1, a regression returning 2 would still pass; assert the captured command status equals 1 in addition to matching the diagnostic.
	ERROR="write the output" $(REVERSE) $(ARGBASH_EXEC) $(TESTDIR)/test-simple.m4 -o $(TESTDIR)/nonexistent-dir/out.sh
  • Files reviewed: 4/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/argbash.m4
if test "$outfname" != '-'
then
printf "%s\\n" "$output" > "$outfname"
printf "%s\\n" "$output" > "$outfname" || die "Couldn't write the output to '$outfname'." 1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed: the recursive generation of the parsing code file is now checked and argbash dies with a message if it fails. The unwritable-output test also asserts the exit status 1 now.

A failed redirection to the output file only produced a shell
diagnostic, argbash still exited with status 0, so callers such as
make carried on with a stale or missing output.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017DxhC3HmTM7TQUzkBZnyH2
@gdevenyi
gdevenyi force-pushed the fix/report-unwritable-output branch from 8ef94d5 to 1dff421 Compare September 13, 2026 02:21
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