derfleck/minishell

expander module

derfleck opened this issue · 0 comments

Before executing the grouped commands from the parser module, variables signified by a $ need to be expanded. This is done by searching through the environment variables and, if the key exists, replacing it with its value. If it doesn't exist, the value is considered to be empty. This seems to be a sufficient implementation, there's nothing in the subject that requires full support of parameter expansion as specified in the bash manual.

As specified, if the text is quoted using ', $ variables don't need to be expanded and the text needs to be treated as is. Only when " is used, the values are expanded.

The expander will be executed before the lexer in order to replace occurences of tokens (<</>>/</>/|) without any space. Example: echo<test should be expanded to echo < test

Resources for possible approaches: