cash icon indicating copy to clipboard operation
cash copied to clipboard

Aliases should take precedence over builtin commands

Open nfischer opened this issue 9 years ago • 0 comments

In bash and zsh, you can do aliases like this:

$ alias ls='ls -l'
$ ls # actually invokes `ls -l`
drwxr-xr-x  5 1000 1000      4096 Jun  9 05:25 dir1
drwx------  3 1000 1000      4096 Jan 15 13:43 dir2
drwxrwxr-x  2 1000 1000      4096 Jan 15 13:42 dir3
drwxrwxr-x  3 1000 1000      4096 Sep 18 18:20 dir4

This is not currently possible in cash, since it looks like calling ls immediately invokes the builtin ls command (no options).

Also, when fixing this, we should make sure to test for the recursive case. If we use alias ls='ls -l', calling ls should invoke the alias, which invokes the builtin.

On the other hand, if we have something more complex:

$ alias ls='ls -l'
$ alias foo='ls'
$ foo # this ultimately invokes `ls -l`

We should make sure to evaluate aliases in such a way that they don't cause cycles.

nfischer avatar Jan 10 '17 07:01 nfischer