Skip to content

[RFE] Proper exit code propagation from custom commands #53

@gnodet

Description

@gnodet

Request for Enhancement: Proper Exit Code Propagation

Problem

Currently, mvx custom commands do not properly propagate exit codes from the underlying scripts to the calling process. This makes it impossible to use mvx commands in CI/CD pipelines or scripts that depend on exit codes for flow control.

Current Behavior

When a custom command's script fails or returns a non-zero exit code, mvx may not propagate this exit code correctly to the shell, making it appear as if the command succeeded when it actually failed.

Expected Behavior

Mvx should:

  1. Capture the exit code from the executed script
  2. Propagate the exit code to the calling process
  3. Maintain consistency with standard Unix tool behavior

Use Cases

CI/CD Pipeline Integration

# This should fail the CI build if formatting is needed
./mvx format-check
if [ $? -ne 0 ]; then
  echo "Code formatting required"
  exit 1
fi

Script Flow Control

# This should work for conditional logic
if ./mvx lint; then
  echo "Linting passed"
else
  echo "Linting failed"
  exit 1
fi

Make Integration

# This should fail the make target if the command fails
format-check:
	./mvx format-check

lint:
	./mvx lint

.PHONY: format-check lint

Current Workaround

Users must manually check command output or use direct tool invocation:

# Instead of relying on exit codes
output=$(./mvx format-check)
if [ -n "$output" ]; then
  echo "Format check failed: $output"
  exit 1
fi

Technical Requirements

  1. Exit Code Preservation: The mvx process should exit with the same code as the underlying script
  2. Error Handling: Distinguish between script failures and mvx internal errors
  3. Consistency: All custom commands should behave consistently with exit code propagation
  4. Backward Compatibility: Existing commands should continue to work as expected

Related Issues

Priority

High - This is essential for proper CI/CD integration and makes mvx commands behave like standard Unix tools that respect exit codes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions