Skip to content

Aliases should take precedence over builtin commands #106

@nfischer

Description

@nfischer

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions