Moving these useful functions out to a separate file

This commit is contained in:
Éibhear Ó hAnluain 2019-09-23 13:24:00 +01:00
parent 42c34cc1c1
commit 4c5e6c09ed
2 changed files with 46 additions and 37 deletions

View file

@ -1,44 +1,9 @@
#!/bin/bash
# A function to make a statement.
declaim () {
echo
echo ${*}
echo "==============="
echo
}
# A function to print the git command to be executed and then to
# execute it
git_command() {
# Print out the command.
echo
echo "git command: ${*}"
# Some variable initialisations
COMMANDSTRING="${*}"
counter=0
UNDERLINESTRING=""
# Build UNDERLINESTRING to be a string of '-' characters the same
# length of all the options passed in.
while [ ${counter} -lt ${#COMMANDSTRING} ]
do
UNDERLINESTRING="${UNDERLINESTRING}-"
counter=$(( ${counter} + 1 ))
done
# Print the pretty underline
echo -n " "
echo ${UNDERLINESTRING}
echo
# Execute the command.
eval ${*}
}
SCRIPT_DIR=$(cd $(dirname ${0}); pwd)
. ${SCRIPT_DIR}/utils.sh
REPO_DIR=${SCRIPT_DIR}/simpleRepo
if [ ${#} -eq 1 ]; then

44
utils.sh Normal file
View file

@ -0,0 +1,44 @@
if [ "${UTILS_LOADED}" = "Y" ]; then
echo "Returning"
return
fi
# A function to make a statement.
declaim () {
echo
echo ${*}
echo "==============="
echo
}
# A function to print the git command to be executed and then to
# execute it
git_command() {
# Print out the command.
echo
echo "git command: ${*}"
# Some variable initialisations
COMMANDSTRING="${*}"
counter=0
UNDERLINESTRING=""
# Build UNDERLINESTRING to be a string of '-' characters the same
# length of all the options passed in.
while [ ${counter} -lt ${#COMMANDSTRING} ]
do
UNDERLINESTRING="${UNDERLINESTRING}-"
counter=$(( ${counter} + 1 ))
done
# Print the pretty underline
echo -n " "
echo ${UNDERLINESTRING}
echo
# Execute the command.
eval ${*}
}
export UTILS_LOADED="Y"