@@ -127,18 +127,21 @@ log_error() {
127127 echo -e " ${RED} [X]${NC} $( date ' +%Y-%m-%d %H:%M:%S' ) - $1 " >&2
128128}
129129log_success () {
130+ echo -e " ${GREEN} [✓]${NC} $( date ' +%Y-%m-%d %H:%M:%S' ) - $1 "
131+ }
132+ echo_success () {
130133 echo -e " ${GREEN} [✓]${NC} $1 "
131134}
132- log_fail () {
135+ echo_error () {
133136 echo -e " ${RED} [X]${NC} $1 " >&2
134137}
135- echo_success () {
138+ echo_color_success () {
136139 echo -e " ${GREEN} $1 ${NC} "
137140}
138- echo_warn () {
141+ echo_color_warn () {
139142 echo -e " ${YELLOW} $1 ${NC} "
140143}
141- echo_error () {
144+ echo_color_error () {
142145 echo -e " ${RED} $1 ${NC} " >&2
143146}
144147
@@ -149,7 +152,7 @@ validate_directory() {
149152
150153 if [ -n " $dir " ]; then
151154 if [[ " $dir " =~ ^- ]]; then
152- log_fail " Error: $type directory parameter '$dir ' cannot start with '-'"
155+ echo_error " Error: $type directory parameter '$dir ' cannot start with '-'"
153156 exit 1
154157 fi
155158 fi
@@ -304,7 +307,7 @@ create_debian_folder() {
304307 echo " ln -s $control_source $repo_root /debian/control"
305308 fi
306309 else
307- log_fail " Error: $control_source is not exist"
310+ echo_error " Error: $control_source is not exist"
308311 fi
309312 fi
310313
@@ -329,7 +332,7 @@ install_debian_depend() {
329332# grep -v '^$' | \
330333# xargs sudo apt install -y
331334 else
332- log_fail " Error: $repo_root /debian/control is not exist"
335+ echo_error " Error: $repo_root /debian/control is not exist"
333336 fi
334337}
335338
@@ -504,7 +507,7 @@ version_compare() {
504507# Function to check if git is installed
505508check_git () {
506509 if ! command -v git > /dev/null 2>&1 ; then
507- echo_error " X Git is not installed" >&2
510+ echo_color_error " X Git is not installed" >&2
508511 echo " Git is required for this script to work." >&2
509512 echo " " >&2
510513 echo " Please install Git using one of the following commands:" >&2
@@ -537,10 +540,10 @@ check_git() {
537540 local git_version=$( git --version | cut -d' ' -f3)
538541
539542 if ! version_compare " $git_version " " $min_version " ; then
540- echo_warn " !️ Git version $git_version is installed, but version $min_version or higher is recommended" >&2
543+ echo_color_warn " !️ Git version $git_version is installed, but version $min_version or higher is recommended" >&2
541544 # Continue anyway, just a warning
542545 else
543- echo_success " √ Git $git_version is installed"
546+ echo_color_success " √ Git $git_version is installed"
544547 fi
545548 fi
546549
@@ -550,7 +553,7 @@ check_git() {
550553# Option to automatically install git (with user confirmation)
551554install_git_if_missing () {
552555 if ! command -v git > /dev/null 2>&1 ; then
553- echo_warn " !️ Git is required but not installed." >&2
556+ echo_color_warn " !️ Git is required but not installed." >&2
554557 read -p " Would you like to install Git now? (y/n): " -n 1 -r
555558 echo
556559 if [[ $REPLY =~ ^[Yy]$ ]]; then
@@ -567,23 +570,23 @@ install_git_if_missing() {
567570 if command -v brew > /dev/null 2>&1 ; then
568571 brew install git
569572 else
570- echo_error " X Homebrew not found. Please install Git manually from https://git-scm.com/download/mac" >&2
573+ echo_color_error " X Homebrew not found. Please install Git manually from https://git-scm.com/download/mac" >&2
571574 return 1
572575 fi
573576 else
574- echo_error " X Unsupported OS. Please install Git manually." >&2
577+ echo_color_error " X Unsupported OS. Please install Git manually." >&2
575578 return 1
576579 fi
577580
578581 # Verify installation
579582 if command -v git > /dev/null 2>&1 ; then
580- echo_success " √ Git installed successfully!"
583+ echo_color_success " √ Git installed successfully!"
581584 else
582- echo_error " X Git installation failed. Please install manually." >&2
585+ echo_color_error " X Git installation failed. Please install manually." >&2
583586 return 1
584587 fi
585588 else
586- echo_error " X Git is required. Exiting." >&2
589+ echo_color_error " X Git is required. Exiting." >&2
587590 return 1
588591 fi
589592 fi
@@ -606,17 +609,17 @@ test_sed_pattern() {
606609
607610 # Test with -E flag
608611 if echo " $test_string " | sed -E " s/${VERSION_PATTERN} /REPLACED/g" | grep -q " REPLACED" ; then
609- echo_success " √ -E flag: Matches"
612+ echo_color_success " √ -E flag: Matches"
610613 else
611- echo_error " X -E flag: No match"
614+ echo_color_error " X -E flag: No match"
612615 fi
613616
614617 # Convert to BRE and test
615618 BRE_PATTERN=$( sed_safe_pattern " $VERSION_PATTERN " )
616619 if echo " $test_string " | sed " s/${BRE_PATTERN} /REPLACED/g" | grep -q " REPLACED" ; then
617- echo_success " √ BRE: Matches"
620+ echo_color_success " √ BRE: Matches"
618621 else
619- echo_error " X BRE: No match"
622+ echo_color_error " X BRE: No match"
620623 fi
621624}
622625
@@ -665,7 +668,7 @@ version_parser() {
665668 return 0
666669 fi
667670
668- log_fail " ERROR: Unable to parse version number '$version '" >&2
671+ echo_error " ERROR: Unable to parse version number '$version '" >&2
669672 return 1
670673}
671674
@@ -686,7 +689,7 @@ display_version_info() {
686689 是否包含构建: ${data[7]}
687690EOF
688691 else
689- log_fail " 数据不完整"
692+ echo_error " 数据不完整"
690693 fi
691694}
692695
@@ -711,7 +714,7 @@ parse_version_assoc() {
711714 version_array[build]=" ${BASH_REMATCH[10]:- } "
712715 return 0
713716 else
714- log_fail " ERROR: Unable to parse version number '$version '" >&2
717+ echo_error " ERROR: Unable to parse version number '$version '" >&2
715718 return 1
716719 fi
717720}
@@ -781,7 +784,7 @@ compare_versions() {
781784
782785 # 检查数组元素个数
783786 if [ ${# parts1[@]} -lt 3 ] || [ ${# parts2[@]} -lt 3 ]; then
784- log_fail " version format error" >&2
787+ echo_error " version format error" >&2
785788 return 3
786789 fi
787790
0 commit comments