Skip to content

Commit a40ff6f

Browse files
committed
refactor
1 parent c1e030d commit a40ff6f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
- name: Print debug data before build
6363
run: |
6464
set -x
65-
echo "Bash Utils version: $(bash-utils bashUtilsVersion)"
65+
echo "Bash Utils version: $(bu bashUtilsVersion)"
6666
echo " Source branch: ${{ env.SOURCE_BRANCH }}"
6767
echo "Destination branch: ${{ env.DESTINATION_BRANCH }}"
6868
echo " Event name: ${{ github.event_name }}"

bash-utils/bash-utils.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ function bashUtilsSetup() {
7979

8080
mkdir -p "$KIRA_GLOBS_DIR"
8181

82-
bash-utils setGlobEnv KIRA_GLOBS_DIR "$KIRA_GLOBS_DIR"
83-
bash-utils setGlobEnv KIRA_TOOLS_SRC "$UTILS_DESTINATION"
84-
bash-utils setGlobPath "/usr/local/bin"
85-
bash-utils setGlobPath "/bin"
82+
bu setGlobEnv KIRA_GLOBS_DIR "$KIRA_GLOBS_DIR"
83+
bu setGlobEnv KIRA_TOOLS_SRC "$UTILS_DESTINATION"
84+
bu setGlobPath "/usr/local/bin"
85+
bu setGlobPath "/bin"
8686

8787
local AUTOLOAD_SET=$(bu getLastLineByPrefix "source $UTILS_DESTINATION" /etc/profile 2> /dev/null || echo "-1")
8888

@@ -95,7 +95,7 @@ function bashUtilsSetup() {
9595
fi
9696

9797
if (! $(bu isCommand cosign)) ; then
98-
echoWarn "WARNING: Cosign tool is not installed, setting up $COSIGN_VERSION..."
98+
bu echoWarn "WARNING: Cosign tool is not installed, setting up $COSIGN_VERSION..."
9999
if [[ "$(uname -m)" == *"ar"* ]] ; then ARCH="arm64"; else ARCH="amd64" ; fi && \
100100
declare -l FILE_NAME=$(echo "cosign-$(uname)-${ARCH}") && \
101101
TMP_FILE="/tmp/${FILE_NAME}.tmp" && rm -fv "$TMP_FILE" && \
@@ -859,7 +859,7 @@ function getArch() {
859859
}
860860

861861
function getArchX() {
862-
echo $(bash-utils getArch 'short')
862+
echo $(bu getArch 'short')
863863
}
864864

865865
function getPlatform() {
@@ -871,18 +871,18 @@ function tryMkDir {
871871
for kg_var in "$@" ; do
872872
kg_var=$(echo "$kg_var" | tr -d '\011\012\013\014\015\040' 2>/dev/null || echo -n "")
873873
[ -z "$kg_var" ] && continue
874-
[ "$(bash-utils toLower "$kg_var")" == "-v" ] && continue
874+
[ "$(bu toLower "$kg_var")" == "-v" ] && continue
875875

876876
if [ -f "$kg_var" ] ; then
877-
if [ "$(bash-utils toLower "$1")" == "-v" ] ; then
877+
if [ "$(bu toLower "$1")" == "-v" ] ; then
878878
rm -f "$kg_var" 2> /dev/null || :
879879
[ ! -f "$kg_var" ] && echo "removed file '$kg_var'" || echo "failed to remove file '$kg_var'"
880880
else
881881
rm -f 2> /dev/null || :
882882
fi
883883
fi
884884

885-
if [ "$(bash-utils toLower "$1")" == "-v" ] ; then
885+
if [ "$(bu toLower "$1")" == "-v" ] ; then
886886
[ ! -d "$kg_var" ] && mkdir -p "$var" 2> /dev/null || :
887887
[ -d "$kg_var" ] && echo "created directory '$kg_var'" || echo "failed to create direcotry '$kg_var'"
888888
elif [ ! -d "$kg_var" ] ; then
@@ -908,9 +908,9 @@ function isDirEmpty() {
908908
function isSimpleJsonObjOrArr() {
909909
if ($(isNullOrEmpty "$1")) ; then echo "false"
910910
else
911-
kg_HEADS=$(echo "$1" | head -c 8)
912-
kg_TAILS=$(echo "$1" | tail -c 8)
913-
kg_STR=$(echo "${kg_HEADS}${kg_TAILS}" | tr -d '\n' | tr -d '\r' | tr -d '\a' | tr -d '\t' | tr -d ' ')
911+
local kg_HEADS=$(echo "$1" | head -c 8)
912+
local kg_TAILS=$(echo "$1" | tail -c 8)
913+
local kg_STR=$(echo "${kg_HEADS}${kg_TAILS}" | tr -d '\n' | tr -d '\r' | tr -d '\a' | tr -d '\t' | tr -d ' ')
914914
if ($(isNullOrEmpty "$kg_STR")) ; then echo "false"
915915
elif [[ "$kg_STR" =~ ^\{.*\}$ ]] ; then echo "true"
916916
elif [[ "$kg_STR" =~ ^\[.*\]$ ]] ; then echo "true"
@@ -921,8 +921,8 @@ function isSimpleJsonObjOrArr() {
921921
function isSimpleJsonObjOrArrFile() {
922922
if [ ! -f "$1" ] ; then echo "false"
923923
else
924-
kg_HEADS=$(head -c 8 $1 2>/dev/null || echo -ne "")
925-
kg_TAILS=$(tail -c 8 $1 2>/dev/null || echo -ne "")
924+
local kg_HEADS=$(head -c 8 $1 2>/dev/null || echo -ne "")
925+
local kg_TAILS=$(tail -c 8 $1 2>/dev/null || echo -ne "")
926926
echo $(isSimpleJsonObjOrArr "${kg_HEADS}${kg_TAILS}")
927927
fi
928928
}

0 commit comments

Comments
 (0)