linux-cookbooks icon indicating copy to clipboard operation
linux-cookbooks copied to clipboard

the function ‘stringToNumber’’s name in util.bash is ambiguous

Open jiacheo opened this issue 2 years ago • 0 comments

As the code wrote, this function is most likely a hash function , name it to 'stringToNumber' may lead the one who use it to 'convert string to number'.

function stringToNumber()
{
    local -r string="${1}"

    checkNonEmptyString "${string}" 'undefined string'

    if [[ "$(existCommand 'md5')" = 'true' ]]
    then
        md5 <<< "${string}" | tr -cd '0-9'
    elif [[ "$(existCommand 'md5sum')" = 'true' ]]
    then
        md5sum <<< "${string}" | tr -cd '0-9'
    else
        fatal '\nFATAL : md5 or md5sum command not found'
    fi
}

https://github.com/gdbtek/linux-cookbooks/blob/master/libraries/util.bash

jiacheo avatar Nov 10 '21 10:11 jiacheo