8f45b40528
12 funciones Bash del dominio shell: utilidades de scripting (bash_log, bash_colors, bash_check_deps, bash_confirm, bash_handle_error, bash_safe_run), manipulacion de texto (convert_text_case), estructura de proyectos (create_project_structure), y operaciones git (git_clean_branches, git_log_visual, git_push_all_remotes, git_repo_status). Cada una con su .sh y .md de frontmatter.
2.0 KiB
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. |
|
|
false | error_go_core |
|
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.