On 2019/07/10 08:29, Robert Elz wrote:
>
>   | Aliases are used internally by bash to store path lookups, by
>   | default.
>
> Really?   I haven't looked at any bash code in a very long time
> (for licensing reasons, I don't want to be corrupted by the GPL)
> but that sounds like a very weird way of implementing things if true.
>
>   | They are simply more efficient.  If functions were better, bash would
>   | implement path lookups by defining a function for each
>
> No it wouldn't, it would (probably actually does, since I can find
> nothing that indicates otherwise) keep a hash table with the results
> of path lookups.   Nothing related to aliases in any way at all.
>   
What do you think aliases are?  They are both a simple hash substitution.

env -i /bin/bash -c 'shopt -s expand_aliases;ls /tmp >&/dev/null;alias
ls=/bin/ls;declare -p BASH_CMDS BASH_ALIASES'          
declare -A BASH_CMDS=([ls]="/usr/bin/ls" )
declare -A BASH_ALIASES=([ls]="/bin/ls" )

Aliases are store/implemented using hashes the same as stored paths
are.  They are effectively the same.



Reply via email to