Skip to content

Commit bf5de2f

Browse files
committed
rename: Prefix private functions with _
1 parent d3e9eb2 commit bf5de2f

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

pkg/src/public/bash-core.sh

+18-18
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
# kill -USR1 $$
1515
# core.trap_remove 'some_handler' 'USR1'
1616
core.trap_add() {
17-
core.private.util.init
17+
core._util.init
1818
local function="$1"
1919

20-
core.private.util.validate_args "$function" $#
20+
core._util.validate_args "$function" $#
2121
local signal_spec=
2222
for signal_spec in "${@:2}"; do
23-
core.private.util.validate_signal "$function" "$signal_spec"
23+
core._util.validate_signal "$function" "$signal_spec"
2424

2525
___global_trap_table___["$signal_spec"]="${___global_trap_table___[$signal_spec]}"$'\x1C'"$function"
2626

2727
# rho (WET)
2828
local global_trap_handler_name=
29-
printf -v global_trap_handler_name '%q' "core.private.trap_handler_${signal_spec}"
29+
printf -v global_trap_handler_name '%q' "core._trap_handler_${signal_spec}"
3030

3131
if ! eval "$global_trap_handler_name() {
3232
local ___exit_code_original=\$?
33-
if core.private.util.trap_handler_common '$signal_spec' \"\$___exit_code_original\"; then
33+
if core._util.trap_handler_common '$signal_spec' \"\$___exit_code_original\"; then
3434
return \$___exit_code_original
3535
else
3636
local ___exit_code_user=\$?
@@ -55,13 +55,13 @@ core.trap_add() {
5555
# kill -USR1 $$
5656
# core.trap_remove 'some_handler' 'USR1'
5757
core.trap_remove() {
58-
core.private.util.init
58+
core._util.init
5959
local function="$1"
6060

61-
core.private.util.validate_args "$function" $#
61+
core._util.validate_args "$function" $#
6262
local signal_spec=
6363
for signal_spec in "${@:2}"; do
64-
core.private.util.validate_signal "$function" "$signal_spec"
64+
core._util.validate_signal "$function" "$signal_spec"
6565

6666
local -a trap_handlers=()
6767
local new_trap_handlers=
@@ -85,7 +85,7 @@ core.trap_remove() {
8585
if [ -z "$new_trap_handlers" ]; then
8686
# rho (WET)
8787
local global_trap_handler_name=
88-
printf -v global_trap_handler_name '%q' "core.private.trap_handler_${signal_spec}"
88+
printf -v global_trap_handler_name '%q' "core._trap_handler_${signal_spec}"
8989
trap -- "$signal_spec"
9090
unset -f "$global_trap_handler_name"
9191
fi
@@ -102,7 +102,7 @@ core.trap_remove() {
102102
# [[ 'variable' == @(foxtrot|golf|echo|variable) ]] && printf '%s\n' 'Woof!'
103103
# core.shopt_pop
104104
core.shopt_push() {
105-
core.private.util.init
105+
core._util.init
106106
local shopt_action="$1"
107107
local shopt_name="$2"
108108

@@ -147,7 +147,7 @@ core.shopt_push() {
147147
# [[ 'variable' == @(foxtrot|golf|echo|variable) ]] && printf '%s\n' 'Woof!'
148148
# core.shopt_pop
149149
core.shopt_pop() {
150-
core.private.util.init
150+
core._util.init
151151

152152
if (( ${#___global_shopt_stack___[@]} == 0 )); then
153153
core.panic 'Unable to pop as nothing is in the shopt stack'
@@ -219,7 +219,7 @@ core.panic() {
219219
if [ -n "$2" ]; then
220220
code=$2
221221
fi
222-
if core.private.should_print_color 2; then
222+
if core._should_print_color 2; then
223223
printf "\033[1;31m\033[4m%s:\033[0m %s\n" 'Panic' "$1" >&2
224224
else
225225
printf "%s: %s\n" 'Panic' "$1" >&2
@@ -329,7 +329,7 @@ core.print_debug_fn() {
329329
core.print_fatal() {
330330
local msg="$1"
331331

332-
if core.private.should_print_color 2; then
332+
if core._should_print_color 2; then
333333
printf "\033[1;35m%s:\033[0m %s\n" 'Fatal' "$msg" >&2
334334
else
335335
printf "%s: %s\n" 'Fatal' "$msg" >&2
@@ -341,7 +341,7 @@ core.print_fatal() {
341341
core.print_error() {
342342
local msg="$1"
343343

344-
if core.private.should_print_color 2; then
344+
if core._should_print_color 2; then
345345
printf "\033[1;31m%s:\033[0m %s\n" 'Error' "$msg" >&2
346346
else
347347
printf "%s: %s\n" 'Error' "$msg" >&2
@@ -353,7 +353,7 @@ core.print_error() {
353353
core.print_warn() {
354354
local msg="$1"
355355

356-
if core.private.should_print_color 2; then
356+
if core._should_print_color 2; then
357357
printf "\033[1;33m%s:\033[0m %s\n" 'Warn' "$msg" >&2
358358
else
359359
printf "%s: %s\n" 'Warn' "$msg" >&2
@@ -365,7 +365,7 @@ core.print_warn() {
365365
core.print_info() {
366366
local msg="$1"
367367

368-
if core.private.should_print_color 1; then
368+
if core._should_print_color 1; then
369369
printf "\033[1;32m%s:\033[0m %s\n" 'Info' "$msg"
370370
else
371371
printf "%s: %s\n" 'Info' "$msg"
@@ -395,7 +395,7 @@ core.ifs_restore() {
395395
# use tput because simple environment variable checking heuristics suffice. Deprecated because this code
396396
# has been moved to bash-std
397397
core.should_output_color() {
398-
if core.private.should_print_color "$@"; then :; else
398+
if core._should_print_color "$@"; then :; else
399399
return $?
400400
fi
401401
}
@@ -428,7 +428,7 @@ core.get_package_info() {
428428
# this function is called automatically by functions that use global variables
429429
# @noargs
430430
core.init() {
431-
core.private.util.init
431+
core._util.init
432432
}
433433

434434
# @description (DEPRECATED) Prints stacktrace

pkg/src/util/util.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# @description Initialize global variables required for shopt and trap functions
44
# @internal
5-
core.private.util.init() {
5+
core._util.init() {
66
if [ ${___global_bash_core_has_init__+x} ]; then
77
return
88
fi
@@ -14,7 +14,7 @@ core.private.util.init() {
1414

1515
# @description Function that runs handlers for a particular signal
1616
# @internal
17-
core.private.util.trap_handler_common() {
17+
core._util.trap_handler_common() {
1818
local signal_spec="$1"
1919
local code="$2"
2020

@@ -38,7 +38,7 @@ core.private.util.trap_handler_common() {
3838
}
3939

4040
# @internal
41-
core.private.util.validate_args() {
41+
core._util.validate_args() {
4242
local function="$1"
4343
local arg_count="$2"
4444

@@ -52,7 +52,7 @@ core.private.util.validate_args() {
5252
}
5353

5454
# @internal
55-
core.private.util.validate_signal() {
55+
core._util.validate_signal() {
5656
local function="$1"
5757
local signal_spec="$2"
5858

@@ -73,7 +73,7 @@ core.private.util.validate_signal() {
7373
# @description Determine if should print color, given a file descriptor
7474
# @arg 1 File descriptor for terminal check
7575
# @internal
76-
core.private.should_print_color() {
76+
core._should_print_color() {
7777
local fd="$1"
7878

7979
if [ ${NO_COLOR+x} ]; then

0 commit comments

Comments
 (0)