Skip to content

foldright/bash-buddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚼 Bash Buddy

License GitHub release GitHub Stars GitHub Forks GitHub issues GitHub repo size

🚼 Bash Buddy(aka. BaBy) contains bash libs and tools that extracted from CI scripts of my projects.



🗂 Lib

a common lib to show trapped error info including stack trace.

provide function trap_error_info::register_show_error_info_handler to register the error-trap handler which show error info when trapped error.

by default, auto call trap_error_info::register_show_error_info_handler when source this script; disable by define TRAP_ERROR_NO_AUTO_REGISTER var.

api functions:

  • trap_error_info::get_stack_trace
  • trap_error_info::register_show_error_info_handler

common util functions.

use short namespace cu, since these functions will be used frequently.

api functions:

  • simple color print functions:
    • cu::red_echo
    • cu::yellow_echo
    • cu::blue_echo
    • cu::head_line_echo
  • validation functions:
    • cu::is_number_string
    • cu::is_blank_string
  • version related functions:
    • cu::version_le
    • cu::version_lt
    • cu::version_ge
    • cu::version_gt
    • cu::is_version_match
    • cu::get_latest_version_match
    • cu::get_oldest_version_match
  • execution helper functions:
    • cu::log_then_run
    • cu::loose_run
    • cu::print_calling_command_line
    • cu::die

java util functions.

api functions:

  • jvu::get_java_version
  • jvu::switch_to_jdk
  • jvu::java_cmd

maven util functions for build.

api functions:

  • maven operation functions:
    • mvu::mvn_cmd

a lib to prepare jdks by sdkman.

api functions:

  • prepare_jdks::switch_to_jdk
  • prepare_jdks::prepare_jdks
  • prepare_jdks::install_jdk_by_sdkman
  • prepare_jdks::load_sdkman
  • prepare_jdks::install_sdkman

⚒️ Tool

Generate source guard to bash lib scripts.

Example:

$ gen_source_guard
#_ source guard begin _#
[ -z "${__source_guard_0EDD6400_96EC_43E4_871A_E65F6781B828:+has_value}" ] || return 0
__source_guard_0EDD6400_96EC_43E4_871A_E65F6781B828="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
readonly __source_guard_0EDD6400_96EC_43E4_871A_E65F6781B828
#_ source guard end _#