diff --git a/src/winusb b/src/winusb index 45fc947..f1dab3a 100755 --- a/src/winusb +++ b/src/winusb @@ -223,17 +223,15 @@ setup_traps(){ # Utility function to check if function parameters quantity is legal # NOTE: non-static function parameter quantity(e.g. either 2 or 3) is not supported util_check_function_parameters_quantity(){ - if [ "${#}" -ne 3 ]; then + if [ "${#}" -ne 2 ]; then printf --\ "%s: FATAL: Function requires %u parameters, but %u is given\n"\ "${FUNCNAME[0]}"\ - 3\ + 2\ "${#}" exit 1 fi - # The name of the function, simply pass "${FUNCNAME[0]}" will do - local function_name="${1}"; shift # The expected given quantity local -i expected_parameter_quantity="${1}"; shift # The actual given parameter quantity, simply pass "${#}" will do @@ -242,7 +240,7 @@ util_check_function_parameters_quantity(){ if [ "${given_parameter_quantity}" -ne "${expected_parameter_quantity}" ]; then printf --\ "%s: FATAL: Function requires %u parameters, but %u is given\n"\ - "${function_name}"\ + "${FUNCNAME[1]}"\ "${expected_parameter_quantity}"\ "${given_parameter_quantity}"\ 1>&2 @@ -399,7 +397,7 @@ switch_terminal_text_color() # Print message with color echo_with_color(){ - util_check_function_parameters_quantity "${FUNCNAME[0]}" 2 "${#}" + util_check_function_parameters_quantity 2 "${#}" local -r message_color="${1}"; shift local -r message_body="${1}" @@ -417,7 +415,7 @@ echo_with_color(){ # $2: Target mountpoint # $3: Exit reason cleanup_mountpoints(){ - util_check_function_parameters_quantity "${FUNCNAME[0]}" 3 "${#}" + util_check_function_parameters_quantity 3 "${#}" set +o errexit # We need to clean up everything we can @@ -490,7 +488,7 @@ hideNoErr(){ # Copy source_file to dest_file, overwrite file if dest_file exists copy_file(){ - util_check_function_parameters_quantity "${FUNCNAME[0]}" 3 "${#}" + util_check_function_parameters_quantity 3 "${#}" source_file="$1" dest_file="$2" whole_current_size="$3" @@ -526,7 +524,7 @@ copy_file(){ # $1: Source filesystem's mountpoint # $2: Target filesystem's mountpoint copy_filesystem_files(){ - util_check_function_parameters_quantity "${FUNCNAME[0]}" 2 "${#}" + util_check_function_parameters_quantity 2 "${#}" # FIXME: Why do we `pulse off` and on here? pulse off @@ -574,7 +572,7 @@ copy_filesystem_files(){ } print_help(){ - util_check_function_parameters_quantity "${FUNCNAME[0]}" 0 "${#}" + util_check_function_parameters_quantity 0 "${#}" echo -e "${RUNTIME_EXECUTABLE_NAME} usage" echo -e "Install a Windows ISO on an FAT partition and edit MBR of the device" @@ -593,7 +591,7 @@ print_help(){ }; declare -fr print_help process_commandline_parameters(){ - util_check_function_parameters_quantity "${FUNCNAME[0]}" 0 "${#}" + util_check_function_parameters_quantity 0 "${#}" if [ "${#RUNTIME_COMMANDLINE_PARAMETERS[@]}" -eq 0 ]; then return 0 @@ -653,7 +651,7 @@ process_commandline_parameters(){ }; declare -fr process_commandline_parameters; shift_array(){ - util_check_function_parameters_quantity "${FUNCNAME[0]}" 1 "${#}" + util_check_function_parameters_quantity 1 "${#}" local -n array_ref="${1}" @@ -674,7 +672,7 @@ shift_array(){ }; declare -fr shift_array trap_return(){ - util_check_function_parameters_quantity "${FUNCNAME[0]}" 1 "${#}" + util_check_function_parameters_quantity 1 "${#}" local returning_function="${1}"