summaryrefslogtreecommitdiffstats
path: root/src/compose/environment.rs
Commit message (Collapse)AuthorAgeFilesLines
* Add doc comments for the Environment structRory Dudley2024-05-201-0/+25
| | | | | Added documentation comments for the Environment struct, which includes uses cases, and defining the fields.
* Allow aliases with the same name as their verbRory Dudley2024-05-201-0/+2
| | | | | | | | | | | | | | | | | Previously, when trying to add an alias that used the same name as its command, an infinite recursion loop would occur, and the program would panic after the call stack got too deep. For instance, something like: alias grep='grep --color=always' would cause it to panic. This patch adds a new field to the Environment struct called 'cs' (for call stack), which can be used to keep track of how many levels deep into the Poem::read() function we are in. At the moment, it only allows going two levels deep, but since it's just a u8 value, this could be increased in the future. The above example now works correctly, but it does mean that aliases within aliases are not possible, currently.
* Add the 'alias' built-in commandRory Dudley2024-03-301-3/+5
| | | | | | | | | | | The shell now has support for aliases (via alias foo=bar). The 'unalias' command is also available to remove aliases. Finally, Environment::aliases was changed to be a HashMap<String, String>, instead of a Vec<String>. Since the verse's verb might change (for instance, it is an environment variable, or an alias), add another check in Poem::recite, which simply continues, instead of running the spellchecker, if the verb is empty.
* Add wrapper for global shell environmentRory Dudley2024-03-301-0/+13
Instead of having to pass around a bunch of different data structures for various shell functions, create the wrapper compose::Environment, which serves as a global shell state. It is configured via login/profile/rc scripts initially, but can of course be modified throughout the lifetime of the shell.