JacobNickerson / juiceOS

Jason Bourne Again SHell
0 stars 0 forks source link

Implement aliases #17

Open JacobNickerson opened 4 days ago

JacobNickerson commented 4 days ago

While seeming trivial at first, aliases allow for a command and args to be aliased. In our current implementation, we only check if the cmdName has any aliases. This does not account for the case where cmdName aliases to a command with additional arguments. We need to implement a way to combine the args after expanding a command to it's aliased command.

Additionally, an alias can contain other aliased commands within it, implying that we may also need to check the new args of a command after alias expansion for aliases as well.

JacobNickerson commented 4 days ago

I should clarify, when I say combine the args, I mean combine the additional arguments of the alias with the previous args. Consider the following example:

alias scream="echo AHHHHHHHHHHH"
alias screamAndDie="scream *dies*"
screamAndDie wow im dead
AHHHHHHHHHHH *dies* wow im dead
cbloodsworth commented 4 days ago

Alias substitution is a POSIX-standard substitution step that should be present in the complete JBash parser. Reference: https://pubs.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_03_01

Don't worry about it for now, just assume that we would have a String -> String hashmap on CmdJBash.