Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jiacheo opened this issue Nov 10, 2021 · 0 comments
Open

Comments

@jiacheo
Copy link

jiacheo commented Nov 10, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant