Open Tishj opened 1 year ago
I've written the logic, completely untested still 😅
Having some trouble figuring out if this specifically needs to happen at execution or doing this while parsing would already be acceptable. And how this would fit with the other expansions that need to happen.
I'm thinking of first adding this to cmd_prefix
, but that is produced from a WORD token, which doesn't have any "rules" associated with it
The WORD tokens shall have the word expansion rules applied to them immediately before the associated command is executed, not at the time the command is parsed.
I believe most of it will happen in execution, since subsequent command expansion can be affected by previous commands. Some things like heredoc word quote removal happens in parser but it's quite minimal afaik.
I wonder if it's worth making some generic state machine tokenizer, i.e. defining only the states, transitions, and token delimiting. Since expansions iteration is somewhat similar to the lexer, and for arithmetic we'll also need some lexer. Some states are not so straight forward though so I don't really see it immediately.
Figured this was the easiest part of Expansion to start with