I've just recognized that (in Debian 7, within Bash 4.2.37) the output of BASH_ALIASES isn't equal to that of alias – which, according to gnu.org's Bash Manual, should be the case:


An associative array variable whose members correspond to the internal list of aliases as maintained by the alias builtin. (see Bourne Shell Builtins). Elements added to this array appear in the alias list; unsetting array elements cause aliases to be removed from the alias list.

I get ls='ls --color=auto' for alias but an empty line for BASH_ALIASES.


Should it be that way? Could this cause any problems in the future?

As I am just curious and battling with all the options for each command causing me enough headache so I really keep quite a distance from making things even more complicated with homebrew aliases, I wonder if this could be a source of trouble in the near future…


BASH_ALIASES is an associative array, so to display it:

$ declare -p BASH_ALIASES
declare -A BASH_ALIASES='([ls]="ls --color=auto" )'


$ for k in "${!BASH_ALIASES[@]}"; do printf '%s => %s\n' "$k" "${BASH_ALIASES[$k]}"; done
ls => ls --color=auto
  • This helps quite a lot, but still: As I (think to know) that one has to declare one's own associative arrays, I didn't thought of having to do this for the system too… which sounds a bit confusing me (as I'm new to Bash scripting and just getting a grip on Arrays at all)
    – erch
    Jan 13 '14 at 11:21
  • @chirp, what do you mean? There's nothing to declare. BASH_ALIASES is already defined, declare -p is to <b>p</b>rint its declaration. Jan 13 '14 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.