---
name: exit_with_status
kind: function
lang: bash
domain: shell
version: "1.0.0"
purity: pure
signature: "exit_with_status(total_steps: int, ok_steps: int, failed_steps: int) -> int"
description: "Calcula el exit code estandar (0=success, 1=failure, 2=partial) a partir de contadores de pasos. Si failed_steps=0 imprime 0 y sale con 0. Si ok_steps=0 imprime 1 y sale con 1. Si hay ambos imprime 2 y sale con 2."
tags: [execution, status, exit-code, standard]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: []
params:
  - name: total_steps
    desc: "número total de pasos ejecutados"
  - name: ok_steps
    desc: "número de pasos exitosos"
  - name: failed_steps
    desc: "número de pasos fallidos"
output: "exit code: 0 (éxito), 1 (fallo), o 2 (parcial)"
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/shell/exit_with_status.sh"
---

## Ejemplo

```bash
source bash/functions/shell/exit_with_status.sh

exit_with_status 5 5 0  # stdout: 0, exit code: 0
exit_with_status 5 0 5  # stdout: 1, exit code: 1
exit_with_status 5 3 2  # stdout: 2, exit code: 2
```

## Notas

Funcion pura: no realiza I/O de sistema, no modifica estado global, no lee variables de entorno. El argumento `total_steps` se recibe para completitud semantica pero la logica solo depende de `ok_steps` y `failed_steps`. El valor se imprime a stdout ademas de usarse como exit code, de modo que el caller puede capturarlo con `$(exit_with_status ...)` o evaluar directamente con `exit_with_status ... ; echo $?`.
