Skip to content

Find alias even when flag order is differently defined #18

@djui

Description

@djui

Currently the following does not work:

# alias l=ls '-l -h -a'
# alias l=ls -lha'
$ ls -l -a -h foo
$ ls -lah foo

should be suggestion: l foo.

The algorithm should change to a heuristic that in most cases finds the alias. What makes this non-trivial is at least:

  1. -- must be respected as flag and argument terminator
  2. -foo is indistinguishable from -f -o -o for some commands but is actually --foo for other commands
  3. -f bar, --foo bar, and --foo=bar are not always identical depending on if -f|--foo is and argument flag or bool flag.

Acceptance criteria and constraints:

  • It's OK if only cases like alias l=ls '-l -h -a' are handled and not yet alias l=ls -lha'.
  • The above case should be solved.
  • No regression should be introduced.
  • It's tolerable if it introduces a neglect able amount of false-positives, e.g.: docker run foo -- -it != dr foo (or dr foo --) if alias alias dr='docker run -it' defined.
  • It's not tolerable for run-time to go up significantly, as one would have to check for all permutations over all aliases defined.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions