Using 'alias' in bash script in OSX

Solution 1:

Aliases aren't interpreted within shell scripts. From bash(1):

Aliases are not expanded when the shell is not interactive, unless the expand_aliases
shell option is set using shopt)

So the script still calls the standard readlink which doesn't know about --help.

Instead of setting expand_aliases (which you have to remember to do so on each system and which may lead to unexpected side-effects in other scripts) I would recommend to use functions instead:

function my_readlink() {
    greadlink "$@"
}
my_readlink --help