Skip to content

Commit

Permalink
src/winusb: Add util_ prefix for utility functions, use alias feature…
Browse files Browse the repository at this point in the history
… to avoid changing it's call

Signed-off-by: 林博仁 <[email protected]>
  • Loading branch information
brlin-tw committed Jun 7, 2017
1 parent f2f86e5 commit d099ecf
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/winusb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ set -o errtrace
set -o nounset
set -o pipefail

## Enable aliases for easy access to functions
shopt -s expand_aliases

for critical_command in realpath basename dirname; do
if ! command -v "${critical_command}" &> /dev/null; then
echo "Fatal: This program requires GNU Coreutils in the executable search path"
Expand Down Expand Up @@ -71,6 +74,10 @@ declare -ir DD_BLOCK_SIZE="((4 * 1024 * 1024))" # 4MiB
# FIXME: No documentation for this non-trivial parameter
declare -i pulse_current_pid=0

## For some reason alias won't be recognized in function if it's definition's LINENO is greater then it's reference in function, so we define it here:
alias echo_with_color=util_echo_with_color
alias switch_terminal_text_color=util_switch_terminal_text_color

init(){
local install_mode

Expand Down Expand Up @@ -635,7 +642,7 @@ pulse(){
# $1:
# <color>: color of the next message
# none: reset color to default
switch_terminal_text_color(){
util_switch_terminal_text_color(){
util_check_function_parameters_quantity 1 $#
case "$1" in
none)
Expand All @@ -660,10 +667,10 @@ switch_terminal_text_color(){
echo -en "\033[0;37m"
;;
esac
}; declare -fr switch_terminal_text_color
}; declare -fr util_switch_terminal_text_color

# Print message with color
echo_with_color(){
util_echo_with_color(){
util_check_function_parameters_quantity 2 "${#}"
local -r message_color="${1}"; shift
local -r message_body="${1}"
Expand All @@ -675,7 +682,7 @@ echo_with_color(){
echo -e "${message_body}"
switch_terminal_text_color none
fi
}; declare -fr echo_with_color
}; declare -fr util_echo_with_color

# Unmount mounted filesystems and clean-up mountpoints before exiting program
# $1: Windows ISO mountpoint
Expand Down

0 comments on commit d099ecf

Please sign in to comment.