Files
fn_registry/bash/functions/shell/bash_safe_run.md
T
egutierrez cfdf515228 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

2.0 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path, source_repo, source_license, source_file
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path source_repo source_license source_file
bash_safe_run function bash shell 1.0.0 impure safe_run(cmd: string, [error_code: string], [error_desc: string]) -> void; setup_error_trap() -> void; error_trap_handler(exit_code: int, line_number: int) -> void Ejecuta comandos con manejo de errores integrado. Incluye trap handler que captura fallos con numero de linea y codigo de salida.
bash
safe
run
error
trap
handler
pendiente-usar
bash_log_bash_shell
false error_go_core
name desc
cmd comando a ejecutar via eval
name desc
error_code codigo identificador del error en caso de fallo; default COMMAND_FAILED
name desc
error_desc descripcion del error a mostrar; default 'El comando fallo: CMD'
exit code 0 si el comando tuvo exito; exit code 1 con mensaje de error formateado si fallo false
bash/functions/shell/bash_safe_run.sh https://gitea-dgg044oo04woo4ggcsws4gk0.organic-machine.com/egutierrez/DevLauncher.git MIT scripts/lib/common.sh

Ejemplo

source bash/functions/shell/bash_safe_run.sh
bash_log_init
setup_error_trap

safe_run "go build ./..." "BUILD_FAILED" "La compilacion fallo"
safe_run "docker compose up -d" "DOCKER_FAILED" "No se pudo iniciar Docker Compose"
safe_run "npm install" "NPM_FAILED"

Notas

safe_run usa eval internamente para ejecutar el comando, lo que permite pasar comandos con pipes y redirecciones como string. Usar con precaucion en entornos con input no confiable.

setup_error_trap instala un trap ERR que llama a error_trap_handler automaticamente en cualquier comando fallido del script, mostrando numero de linea y codigo de salida.

error_trap_handler no llama a exit — el caller decide si continuar o abortar. Muestra la ruta al log para debugging.